iphone - 在自定义 UINavigationController 中强制执行特定 rootViewController 的推荐方法是什么?

标签 iphone objective-c ios cocoa-touch uinavigationcontroller

我正在构建一个将由其他 iPhone 开发人员使用的 iPhone SDK。

此 SDK 的主要用途是呈现一个 UI,使用户能够完成某个过程。

此 UI 应包装在 UINavigationController 中,因为它由构成流程的多个 UIViewController 组成。

我希望将使用我的 SDK 的开发人员初始化我的自定义 UINavigationController,然后以他们想要的方式呈现它。

我想强制我的自定义导航 Controller 的 rootViewController 将是 SDK 中的特定 ViewController,开发人员将无法使用不同的 rootViewController 对其进行初始化。

实现此目标的推荐方法是什么?

最佳答案

你不应该继承 UINavigationController,如 Apple 文档中所写。

This class is not intended for subclassing. Instead, you use instances of it as-is in situations where you want your application’s user interface to reflect the hierarchical nature of your content.

如果您使用的是 iOS 5,请为 UIViewController 使用新的包含 API。

Implementing a Container View Controller

使用这种方法,您可以强制执行根 Controller 并将其隐藏给用户。

如果 iOS 5 不可用,请参阅我之前的回答 Handle different view controllers within an application: creating Custom Content View Controllers .

希望对您有所帮助。

关于iphone - 在自定义 UINavigationController 中强制执行特定 rootViewController 的推荐方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11239803/

相关文章:

ios - UITableViewCell 中点击的 MKMapView 的详细信息

ios - 如何在 Firebase 远程配置中使用字符串而不是 plist 设置默认值?

ios - NSData的内容是单独引用计数的吗?

ios - 按下 iOS 时按钮没有动画

ios - Xcode项目中使用的静态库之间的冲突

iphone - OpenGL2.0在iPhone操作系统硬件(iPhone/iPod Touch)中占有多少市场份额

iphone - Div 在 iphone 上不跨越整个宽度

iphone - 为 iPhone 设计 <select> 标签

ios - 以编程方式获取导航栏的高度

objective-c - CABasicAnimation 没有任何效果