Objective c UINavigationController—;通过presentViewController呈现时,推送和弹出之间的左右翻转动画

Objective c UINavigationController—;通过presentViewController呈现时,推送和弹出之间的左右翻转动画,objective-c,ipad,uinavigationcontroller,uiviewanimation,Objective C,Ipad,Uinavigationcontroller,Uiviewanimation,假设你有: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after appl

假设你有:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    UIViewController *rootViewController = [[UIViewController alloc] init];
    rootViewController.view.backgroundColor = [UIColor whiteColor];

    [self.window setRootViewController:rootViewController];
    [self.window makeKeyAndVisible];

    UINavigationController *modal = [[UINavigationController alloc] initWithRootViewController:[[PTFrontViewController alloc] init]];
    modal.modalPresentationStyle = UIModalPresentationFormSheet;
    [rootViewController presentViewController:modal animated:YES completion:NULL];

    return YES;
}
鉴于此示例,
PTFrontViewController
PTBackViewController
视图控制器没有什么有趣的地方

如何从
PTFrontViewController
中推送
PTBackViewController
的实例,如
uiviewmanimationtransitionflipfromlight
uiviewmanimationtransitionflipfromright
中的动画

我已经很清楚这三件事:

  • 这并不是您应该如何使用
    presentViewController
  • UINavigationController
    的默认动画有一个很好的理由
  • 如何在按下和弹出时“自定义”UINavigationController的默认动画,有几种答案,但如果您自己尝试代码,您会注意到,当通过
    presentViewController
    显示视图控制器时,会出现无法正确设置动画的阴影和背景视图

  • 所以请记住这些事情。谢谢。

    首先-忘记
    UINavigationController
    。如果不需要默认动画,只需在控制器中插入
    UINavigationBar
    。这会变得容易一点

    第二,这是一个困难的问题,您不能仅在模态控制器中创建这样的动画,因为背景不会被重新绘制

    诚恳地说,我看到的最简单的解决方案就是忘记模态控制器,只需将视图控制器添加为根控制器的子控制器。然后,您可以控制所有动画,但您必须自己编写所有内容(包括背景淡入淡出)