简体   繁体   English

在iPhone中实现多个视图

[英]Implementing multiple views in iPhone

I am trying to develop an app which can have multiple views (up to 30). 我正在尝试开发一个可以具有多个视图(最多30个)的应用程序。 Each view will have have similar navigation but the content will be different. 每个视图将具有相似的导航,但是内容将有所不同。 Do I have to create 30 view controllers or can I get around by creating a view controller for the data (content) alone. 我是否必须创建30个视图控制器,还是可以仅为数据(内容)创建一个视图控制器来解决这个问题? I am sure creating multiple view controllers is going to be inefficent. 我确信创建多个视图控制器将是无效的。 I will be using the UINavigationController for sure. 我肯定会使用UINavigationController。

Any information, links would be really appreciated. 任何信息,链接将不胜感激。

Thanks 谢谢

Amy 艾米

One view should be enough. 一种观点就足够了。 Similar to Contacts application you have table view with each row containing different contact but when you select a name you are shown view with the details of the specific contact. 与“ 联系人”应用程序类似,您具有表格视图,每一行包含不同的联系人,但是当您选择姓名时,将显示带有特定联系人详细信息的视图。

The view is the same for every contact but the data are specific for the contact. 每个联系人的视图都是相同的,但是数据是特定于联系人的。 You reuse the same view but you populate it with different data. 您重复使用相同的视图,但使用不同的数据填充它。

More info on UINavigationController and UIViewController in View Controller Programming Guide for iPhone OS . iPhone OS的《视图控制器编程指南》中有关UINavigationController和UIViewController的更多信息。

You can place a UIView in the center part of your window for the content. 您可以将UIView放在内容窗口的中心部分。 This view should fill the space not taken up by your navigation bar. 该视图应填充导航栏未占用的空间。 You can then switch the content in this view by adding a subview to it or by changing the content inside. 然后,可以通过向其添加子视图或更改其中的内容来切换该视图中的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM