问题描述
我想使用addChildViewController的相同功能,但对于版本4.3(addChildViewController仅在版本5中可用)。
提前致谢。
I would like to use the same functionality of addChildViewController, but for the version 4.3 (addChildViewController is only available in version 5).Thanks in advance.
推荐答案
虽然不推荐,但您可以创建一个 UIViewController 访问它的视图
属性并将其设置为主视图
的子视图main UIViewController
正在管理。它有效,我从来没有遇到过这个问题。
Although it's not recommended, you can create an instance of a UIViewController
access it's view
property and set it as a subview of the main view
your main UIViewController
is managing. It works, and I never experienced a problem with this.
这就是说,建议的方法是有一个 NSObject
子类充当您的子控制器,而不是使用 UIViewController
,因为它有特殊行为。
That said, the recommended way is to have a NSObject
subclass to act as your sub-controller, and not use a UIViewController
as it has special behavior.
这篇关于适用于iOS 4.3的addChildViewController替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!