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開關動畫開始,但是當我釋放時,它會再次重複動畫。所以基本上動畫發生兩次,我只希望它發生一次。
任何想法?
感謝提前:)