iPhone:查看/编辑/列表控制器

发布于 2025-01-03 15:04:10 字数 249 浏览 3 评论 0原文

我有一个客户视图控制器,它是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

红颜悴 2025-01-10 15:04:10
  1. 创建一个 CustomerListController 来查看所有客户。
  2. 创建一个 CustomerViewController 用于查看和编辑详细信息。
  3. CustomerViewController 子类化,调用它 CustomerAddController 进行创建,因为这需要更多的功能。

Core Data Recipes 应用程序将为您提供一些有关此问题的良好指示。

如果您希望它仅在您点击“保存”后创建记录,您需要:

  1. 创建一个额外的 NSManagedObjectContext(假设您使用的是 Core Data)。
  2. 仅将该上下文传递给 CustomerAddController 类的实例(视图类不需要)。
  3. 点击保存按钮后,您需要合并CustomerListController中的两个NSManagedObjectContext类。
  1. Create a CustomerListController for seeing ALL customers.
  2. Create a CustomerViewController for viewing and editing the detail.
  3. Subclass the CustomerViewController calling it CustomerAddController 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:

  1. Create an additional NSManagedObjectContext, assuming you're using Core Data.
  2. Pass that context to the instance of the CustomerAddController class only (not needed for the view class).
  3. When the Save button is hit, you'll need to merge the two NSManagedObjectContext classes in the CustomerListController.
糖粟与秋泊 2025-01-10 15:04:10

我相信联系人应用程序的方式是:

  • 联系人列表是 UINavigationController 中的 UITableViewController
  • 触摸 + 模态地呈现(从导航控制器)一个不同的视图控制器,用于添加联系人
  • 触摸完成将新的视图控制器推送到导航控制器上查看新创建的联系人,但它还不可见,因为添加视图控制器的模态呈现的联系人位于顶部。随后,模态视图控制器立即消失,显示新创建的联系人。

为了回答您的问题,我建议使用三种不同的视图控制器,就像联系人应用程序一样。

I believe the way the Contacts app does it is:

  • Contacts list is a UITableViewController in a UINavigationController
  • Touching the + modally presents (from the navigation controller) a different view controller for adding the contact
  • Touching Done pushes a new view controller onto the navigation controller for viewing the newly created contact, but it isn't visible yet because the modally presented contact adding view controller is on top. Immediately afterwards, the modal view controller is dismissed, revealing the newly created contact.

To answer your question, I'd suggest using three different view controllers, just like the Contacts app.

尽揽少女心 2025-01-10 15:04:10

我建议您为每项任务使用不同的视图,因为使用一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文