2011-09-18 5 views
0

약간의 문제가 있습니다. 나는 UILongPressGestureRecognicer가있는 UILabel을 가지고있다. UILongPressGestureRecognizer가 호출되면 내 앱은 플립 애니메이션을 사용하여 새 뷰로 전환해야합니다. Xcode : 내 플립 애니메이션이 두 번 플립되는 이유는 무엇입니까?

내가 GestureRecognizer에 사용한 코드입니다 :

UILongPressGestureRecognizer *labelLongPressRecognizer; 
labelLongPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LoadLabelSettings:)]; 

labelLongPressRecognizer.numberOfTouchesRequired = 1; 
labelLongPressRecognizer.minimumPressDuration = 2.0; 

[NewLabel addGestureRecognizer:labelLongPressRecognizer]; 

이 뷰의 코드 전환 애니메이션입니다 :

CGContextRef context = UIGraphicsGetCurrentContext(); 

[UIView beginAnimations:nil context:context]; 
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:1.0]; 

[self.view addSubview:LabelSettingsViewController.view]; 

[UIView commitAnimations]; 

if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight || self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 

    LabelSettingsViewController.view.frame = CGRectMake(0, 0, 480, 300); 

} 

내 문제는 내가에 누르고 있으면 내 UILabel 스위치 애니메이션이 시작됩니다.하지만 릴리스하면 애니메이션이 다시 반복됩니다. 따라서 기본적으로 애니메이션은 두 번 발생하며 한 번만 애니메이션을 실행하려고합니다.

아이디어가 있으십니까? 사전 :

답변

1

는 예를 들어, 당신이 보낸 사람의 상태를 확인 있는가에

감사합니다,

- (void)LoadLabelSettings:(UILongPressGestureRecognizer *)sender 
{ 
    if (sender.state == UIGestureRecognizerStateEnded) // or whatever 
     // then do the flipping stuff 
} 

체크 아웃 긴 언론 것에 대해 이야기은 "UILongPressGestureRecognizer 클래스 참조"의 "개요" 계속해서 나는 많은 사건이 촉발 될 수 있다고 추정한다 :

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UILongPressGestureRecognizer_Class/Reference/Reference.html

관련 문제