我正在构建一个将由其他 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/