iPhone:淡化两个RootViewControllers之间的过渡 [英] iPhone: Fade transition between two RootViewControllers

查看:107
本文介绍了iPhone:淡化两个RootViewControllers之间的过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Obj-C MonoTouch C#答案很好。

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

The initial UIWindow's RootViewController is a simple login screen.

window.RootViewController = loginScreen;

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

After login, I set the Root to the main app

window.RootViewController = theAppScreen;

如何在此实例中的两个RootViewController之间进行淡入淡出过渡?

How do I Fade-transition between the two RootViewControllers in this instance?

推荐答案

我可能会建议一种能让你动画的不同方法。只需转到 theAppScreen 控制器首先,如果您需要用户登录,请让它执行 presentViewController 进入 loginScreen (如果您希望它看起来直接进入登录屏幕,则无需为此步骤设置动画)。这样,当你成功登录后,loginScreen只能 dismissViewControllerAnimated ,你的动画又回到主 theAppScreen 。 (显然,如果你想要淡入效果,不要忘记将控制器的 modalTransitionStyle 设置为 UIModalTransitionStyleCrossDissolve 。)

I might suggest a different approach that will get you your animation. Just go to the theAppScreen controller first, and if you need the user to log in, have it do the presentViewController to get to the loginScreen (you don't have to animate this step if you want it look like it went directly to the login screen). That way, when you've successfully logged in, the loginScreen can just dismissViewControllerAnimated and you've got your animation back to the main theAppScreen. (Obviously, if you want the fade effect, don't forget to set the controller's modalTransitionStyle to UIModalTransitionStyleCrossDissolve.)

如果您已经设置好更改 rootViewController ,那么我能想到的唯一方法就是这样做(而且我不喜欢它会做类似的事情:

If you're dead set on changing your rootViewController, the only way I can think of doing it (and I don't like it) would be to do something like:

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;
}];

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

The first technique seems much cleaner to me.

这篇关于iPhone:淡化两个RootViewControllers之间的过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆