简体   繁体   English

在UIViewController之间切换的正确设计模式是什么?

[英]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? 切换到控制器及其视图时,如何确保其方向正确?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 内存累积,在UIViewControllers之间切换,可以吗? - Memory Accumilation, switching between UIViewControllers, what is ok? 使用UISegmentedControl在UIViewControllers之间切换 - Switching between UIViewControllers with UISegmentedControl 在UIViewController之间切换时发生什么类型的内存问题? - What type of memory issue is happening when switching between UIViewControllers? 在UINavigationController中的UIViewController之间切换 - Switching between UIViewControllers within UINavigationController 在故事板上的UIViewController之间切换 - Switching between UIViewControllers in story board 在多个UIViewController之间切换时如何在UIImageView中保留图像 - How to keep an image in a UIImageView when switching between multiple UIViewControllers 用于构造需要来自多个UIViewControllers的数据的对象的设计模式 - Design Pattern for constructing an object which requires data from multiple UIViewControllers 在iOS中切换UIViewControllers不起作用 - Switching UIViewControllers in iOS not working UIView和UIViewControllers设计模式 - UIView & UIViewControllers desing pattern 单击按钮以编程方式切换UIViewControllers - Switching UIViewControllers programmatically on button click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM