iPhone:查看/编辑/列表控制器
我有一个客户视图控制器,它是 UITableViewController 的子类。它有一个列出所有客户的列表。我的右上角有一个 + 按钮。我想要做到这一点,以便当人们单击 + 时,它将转到添加客户屏幕,单击保存后,它将像 iPhone 联系人列表一样,然后显示新添加的客户。
我需要为每个视图创建一个控制器吗?一个用于显示列表,一个用于添加人员,一个用于查看联系人,然后另一个用于编辑联系人?或者我应该使用一个控制器,然后将 IB 中的一堆视图添加到单个视图控制器中?
I have a customer view controller that is a subclass of UITableViewController. It has a list that lists all the customers. I have a + button in the top right. I want to make it so when people click the + it will go to the add customer screen and after you click save it will act JUST like the iphone contacts list and then display the newly added customer.
Would I need to create a controller for each view? One to display the list, one to add the person and one to view the contact then another to edit the contact? Or should I use one controller and just add a bunch of views in IB into the single view controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CustomerListController
来查看所有客户。CustomerViewController
用于查看和编辑详细信息。CustomerViewController
子类化,调用它CustomerAddController
进行创建,因为这需要更多的功能。Core Data Recipes 应用程序将为您提供一些有关此问题的良好指示。
如果您希望它仅在您点击“保存”后创建记录,您需要:
NSManagedObjectContext
(假设您使用的是 Core Data)。CustomerListController
中的两个NSManagedObjectContext
类。CustomerListController
for seeing ALL customers.CustomerViewController
for viewing and editing the detail.CustomerViewController
calling itCustomerAddController
for creating, as this will need a little more functionality.Core Data Recipes application will give you some good pointers around this.
If you want it to only create the record after you hit save, you'll need to:
NSManagedObjectContext
, assuming you're using Core Data.CustomerAddController
class only (not needed for the view class).NSManagedObjectContext
classes in theCustomerListController
.我相信联系人应用程序的方式是:
为了回答您的问题,我建议使用三种不同的视图控制器,就像联系人应用程序一样。
I believe the way the Contacts app does it is:
To answer your question, I'd suggest using three different view controllers, just like the Contacts app.
我建议您为每项任务使用不同的视图,因为使用一个 IB 文件会使用更多内存,就好像您为每项任务使用不同的 IB 和视图控制器一样,那么不会使用太多内存,并且在完成一项任务后,例如,当您保存时用户详细信息释放该视图的内存,以便您的应用程序不会使用太多内存。
I suggest you to use different views for every task because using one IB file uses more memory where as if you use different IBs and view controllers for every task then there is not too much memory is used and after completing one task for example when you save the user detail free the memory for that view so that you app do not use much memory.