没有为UIViewControllers工作翻转动画

时间:2014-05-05 11:06:49

标签: ios objective-c uiviewcontroller core-animation

我正在尝试在ViewController之间创建翻转动画,但它不起作用:

BHAppDelegate *app = [[UIApplication sharedApplication] delegate];
UINavigationController *tabBarController = [self.storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];

BHViewController *leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenu"];

PKRevealController *revealController = [PKRevealController revealControllerWithFrontViewController:tabBarController leftViewController:leftViewController];
[revealController setMinimumWidth:220 maximumWidth:220 forViewController:tabBarController];

[UIView beginAnimations:@"animation" context:nil];
    app.window.rootViewController = revealController;
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

1 个答案:

答案 0 :(得分:0)

很抱歉,为什么要在UIWindow上将revealController设置为rootViewController? 我认为上面的代码在你的rootViewController中,所以从你的rootViewController你应该用这种方式来呈现revealController

    [revealController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentViewController:revealController animated:YES completion:nil];

revealController中你会用这种方式解散并回到rootViewController

    [self dismissViewControllerAnimated:YES completion:nil];