【发布时间】:2009-08-18 02:22:47
【问题描述】:
(顺便说一下,我不使用接口 建造者)
我有一个由根 UIViewController 组成的小项目,它管理 5 个带有 UITabBar 的其他视图控制器,我没有使用 UITabBarController。 The Root View Controller only ever keeps one of its View Controllers instantiated, when a tab bar item is selected, the View Controller associated with that tab gets instantiated, the old one is removed, the new one is added as a subview and the old one被释放。
每个 View 控制器都有一个 UIPickerView(具有 UIDatePicker 的除外)。当用户从选项卡 1 转到选项卡 2 并返回到选项卡 1 时,我希望视图控制器在选择器中使用与以前相同的选定行进行实例化,即使它已被释放,所以我理解它最好使用 Model 类的实例来存储有关 View Controller 状态的信息,然后在每个 View Controller 中创建 init 方法,这些方法使用给定的参数进行初始化,该参数是 Model 的实例。
那么有人可以帮帮我吗?模型类应该是什么样的?它应该叫什么名字?它的一个实例如何用于存储有关一个 View Controller 状态的信息,而另一个实例存储有关另一个不同 View Controller 的信息?我真的很想把这个简单的项目做得尽可能完美,并遵循 MVC 设计模式,这样我就可以将所有其他选项卡栏应用程序都以此为基础。
谢谢!!
【问题讨论】:
标签: iphone cocoa-touch model model-view-controller