xcode 有没有办法在不使用 UINavigationController 的情况下更改 iOS 中的视图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5279313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to change Views in iOS without using UINavigationController?
提问by Tony Lukasavage
I have a login page at the beginning of my app that I do not want on the view stack. Is there a way to load my first post-login view after the login without using UINavigatorController
?
我的应用程序开头有一个登录页面,我不想在视图堆栈中显示该页面。有没有办法在登录后加载我的第一个登录后视图而不使用UINavigatorController
?
Is there a better way to be doing this? Should I be using 2 UINavigationControllers
? Is there a way to change the RootViewController
for a UINavigationController
?
有没有更好的方法来做到这一点?我应该使用 2UINavigationControllers
吗?有没有办法改变RootViewController
a UINavigationController
?
回答by hoha
Yes, you can change root controller of window. Set window's property rootViewController
to new controller and you're done. Don't forget though that first controller (one you are removing) will not receive viewWillDisappear:
and viewDidDisappear:
messages. Send them yourself before switching controllers if you're interested in them.
是的,您可以更改窗口的根控制器。将窗口的属性设置rootViewController
为新控制器,您就完成了。不要忘记尽管第一个控制器(您要删除的控制器)不会收到viewWillDisappear:
和viewDidDisappear:
消息。如果您对它们感兴趣,请在切换控制器之前自己发送它们。
回答by aceofspades
You might also look at UIViewController#presentViewController