3

我需要推视图控制器到另一个视图控制器。推动ViewController与模态动画(水平翻转)

menuVC -> VC1 ->VC2 

打算从menuVC到VC1不需要动画,但会从VC1 VC2到从VC2 VC1到需要发生翻转animaton。

但是,从VC2到menuVC时,不需要动画。

我使用下面的代码:

(从how to push a viewController with flip animation

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; 
FlashCardVC *flashCardVC = [[FlashCardVC alloc] init]; 
[self.navigationController pushViewController:flashCardVC animated:NO]; 
[UIView commitAnimations]; 

,屏幕会完全空白,当我尝试做以上。

出了什么问题?

回答

15

你真的应该现在使用基于块的动画。另外,如果您从同一故事板中的控制器实例化故事板控制器,则可以使用self.storyboard更轻松地访问故事板。

-(IBAction)flipToNext:(id)sender { 
    SecondController *next = [self.storyboard instantiateViewControllerWithIdentifier:@"Next"]; 
    [self.navigationController pushViewController:next animated:NO]; 
    [UIView transitionWithView:self.navigationController.view duration:1 options:UIViewAnimationOptionTransitionFlipFromRight animations:nil completion:nil]; 
} 
+0

关于如何更新iOS 8风格转换的答案的任何想法? – SleepsOnNewspapers 2015-01-31 04:01:33

+0

@ hsavit1,你问的是什么样的iOS 8样式转换? – rdelmar 2015-01-31 06:15:05

1

大答案: Showing pushviewcontroller animation look like presentModalViewController

(代码)

//UIViewController *yourViewController = [[UIViewController alloc]init];</s> 

    [UIView beginAnimations: @"Showinfo"context: nil]; 
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.75]; 
    [self.navigationController pushViewController: yourViewController animated:NO]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; 
    [UIView commitAnimations]; 

然而,由此产生一个空白屏幕也。

相反,如果使用的是故事板,最好通过故事板实例:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle bundleForClass:[self class]]]; 

YourViewController *yourViewController = [storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"]; 

yourViewControllerID在故事板下的身份检查器yourviewcontroller类设置。

+0

请将此答案标记为已接受,以便此问题不会显示在未答复的问题列表中。 – memmons 2013-02-10 16:41:05