iPhone:淡化两个RootViewControllers之间的过渡

Ian*_*ink 10 iphone transition xamarin.ios ios

Obj-CMonoTouch C#答案很好.

最初的UIWindow的RootViewController是一个简单的登录屏幕.

window.RootViewController = loginScreen;
Run Code Online (Sandbox Code Playgroud)

登录后,我将Root设置为主应用程序

window.RootViewController = theAppScreen;
Run Code Online (Sandbox Code Playgroud)

在这个实例中,如何在两个RootViewControllers之间进行淡入淡出过渡?

Rob*_*Rob 19

我可能会建议一种能让你动画的不同方法.刚去theAppScreen控制第一,如果你需要用户登录,有它做presentViewController去的loginScreen(你没有,如果你想让它看起来像它去直接登录屏幕动画此步骤).这样,当您成功登录后,loginScreen就可以了dismissViewControllerAnimated,您可以将动画恢复到主要状态theAppScreen.(显然,如果你想要淡入效果,不要忘记将控制器设置modalTransitionStyleUIModalTransitionStyleCrossDissolve.)

如果你已经决定改变你rootViewController,那么我能想到做的唯一方法(而且我不喜欢它)就是这样做:

MainAppViewController *controller = [[MainAppViewController alloc] initWithNibName:@"MainAppViewController" bundle:nil];

// animate the modal presentation

controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self.window.rootViewController presentViewController:controller 
                                             animated:YES
                                           completion:^{

    // and then get rid of it as a modal

    [controller dismissViewControllerAnimated:NO completion:nil];

    // and set it as your rootview controller

    self.window.rootViewController = controller;
}];
Run Code Online (Sandbox Code Playgroud)

第一种技术对我来说似乎更清洁.