定制容器视图控制器 [英] Custom container view controller

查看:111
本文介绍了定制容器视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建自己的容器视图控制器,例如 UINavigationController UITabBarController 。文件说我不应该这样做,但为什么不呢?导航和tabbar容器是很好的例子,这样的东西是可能的,并且工作得非常好。另外我知道iPhone有小屏幕,人们不应该通过导航按钮等弄乱它,但是在iPad上有很多空间,将它分成许多视图控制器会给我们很大的机会。

I want to create my own container view controller, i.e. something like UINavigationController or UITabBarController. Docs say I should not do that, but why not? Navigation and tabbar containers are good examples that such thing is possible and works really well. Also I understand that iPhone has small screen and people shouldn't mess it up by navigation buttons, etc., but on an iPad there is a lot of space and splitting it to many view controllers would give us great opportunities.

我有一种感觉Apple还没有添加这样的API,但他们会。几天前他们已经添加了关于iPad特定控制器的文档(是的,容器控制器),并且他们将文本修改为不那么令人生畏的东西。

I have a feeling Apple didn't add such API yet, but they will. Few days ago they've added docs about iPad-specific controllers (yeah, container ones) and they've modified texts to something less-forbidding.

无论如何......如果我尝试在一个屏幕上使用两个或更多视图控制器,我可能会遇到什么问题?我知道只有其中一个会获得方向更改或低内存警告等事件,因此我必须将这些事件传递给包含的VC。我担心与未来版本的iOS的兼容性,因为如果他们将添加新事件,那么包含的VC将不会执行从 UIViewController 继承的默认操作。还要别的吗?你认为我的应用程序可能会被Apple拒绝吗?也许有其他方法可以在每个屏幕上保留一些视图元素而不会将大量相同的代码复制到每个VC?

Anyway... what problems may I have if I try to use two or more view controllers on one screen? I know only one of them will get events like orientation change or low memory warning, so I have to pass these events to contained VCs. I'm afraid about compatibility with future versions of iOS, cause if they'll add new events, then contained VCs won't execute default actions inherited from UIViewController. Anything else? Do you think my app may be rejected by Apple? Maybe there is other way to have some view elements persistent on each screen without copying a lot of same code to every VC?

提前致谢。

推荐答案

iOS5现在支持此功能。有关示例代码,请参阅此问题:容器视图控制器示例

This is now supported in iOS5. See this question for some example code: Container View Controller Examples

这篇关于定制容器视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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