iphone - 为什么 Apple 不允许 UINavigationController 的子类化?除了子类化之外,我还有哪些选择?

标签 iphone cocoa-touch uikit subclass subclassing

我目前正在构建一个选项卡式 iPhone 应用程序,其中每个选项卡的 View Controller 都是 UINavigationController 的一个实例,并且每个 UINavigationController 实例的每个子 Controller 都是一个UITableViewController 的实例。理想情况下,我想对 UINavigationController 进行子类化,以便每个选项卡的 Controller 都是 UINavigationController 的子类(显然,除了具有所有标准的 UINavigationController 功能之外)作为与其子 Controller 关联的每个 TableView 的数据源和委托(delegate)。尝试这样做似乎破坏了子类中的基本 UINavigationController 功能。

正如 Apple 在其 iPhone 文档中所说的那样,不应继承 UINavigationController 的子类,而且当这样做时事情似乎会崩溃,我想知道应该如何扩展 UINavigationController 的 没有子类化的功能,一般来说,在进行 Cocoa 开发时应该如何解决子类化的限制。

谢谢!

最佳答案

到底为什么要让 UINavigationController 充当表的数据源? UITableViewController 的全部要点是,您可以对它进行子类化,并且它充当 UITableView 的数据源,它也放置在并填充父 View 中。

关于iphone - 为什么 Apple 不允许 UINavigationController 的子类化?除了子类化之外,我还有哪些选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1937616/

相关文章:

iphone - 如何在Cocos2d中隐藏屏幕左下角的FPS数字

iphone - 错误 : "-[NSCFString sizeWithTextStyle:]: unrecognized selector" in IPhone SDK

iphone - 为什么 UIButton 标题不显示?

ios - 如何在 Did DeSelect 中删除字典数组中的值?

ios - 首次应用约束时出现意外行为

iphone - 权限被拒绝-iPhone Froze-iOS6

ios - 可编辑的 UITableView,单元格中的 UITextField,按下完成时存储数据

ios - 使用特定动态类型尺寸的字体

iphone - 向 UITableView 子类添加属性

ios - 退出 iPhone 应用程序的正确方法?