[英]What is the right design pattern for switching between UIViewControllers?
I have an app which has two main controllers: A GJClientSelectionController, which is just a regular UIViewController with a view containing a scrollview, and a CGClientDetailController, which is a custom UIViewController that manages a custom tab bar and a controller for each one. 我有一个具有两个主要控制器的应用程序:一个GJClientSelectionController,它是一个常规UIViewController,带有包含滚动视图的视图;一个CGClientDetailController,它是管理每个选项卡的自定义UIViewController和一个控制器的自定义UIViewController。 I switch between the controllers as the user moves between each part of the app.
当用户在应用程序的各个部分之间移动时,我会在控制器之间切换。
The problem is, I'm not sure what the correct design pattern is. 问题是,我不确定正确的设计模式是什么。 Until iOS6, I was just setting each one as the value of the window's rootViewController property.
在iOS6之前,我只是将每个参数设置为窗口的rootViewController属性的值。 It worked well, but if the device is rotated and then I switch controllers, the newly visible controller will not have received the rotation notification and will be drawn wrong until the user rotates the device.
它运行良好,但是如果旋转设备,然后我切换控制器,则新可见的控制器将不会收到旋转通知,并且会在用户旋转设备之前被绘制为错误。 I'm also experimenting with having a regular UIViewController that I call masterController, and setting that as the rootViewController, then adding the other two controllers as childViewControllers.
我还尝试使用一个常规的UIViewController(称为masterController),并将其设置为rootViewController,然后将其他两个控制器添加为childViewControllers。 The only thing is that if I make the view for the childViewController hidden, it still misses rotation notifications.
唯一的事情是,如果我隐藏childViewController的视图,它仍然会错过旋转通知。
What's the right design pattern for moving between UIViewControllers? 在UIViewController之间移动的正确设计模式是什么? How can I ensure that a controller and its view has the correct orientation when I switch to them?
切换到控制器及其视图时,如何确保其方向正确?
看看这篇文章: 如何在iOS 6中将UIViewController强制设为纵向
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.