在UINavigationController层次结构中刷新UITableView的最佳方法是什么 [英] What's the best way to refresh a UITableView within a UINavigationController hierarchy

查看:122
本文介绍了在UINavigationController层次结构中刷新UITableView的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iPhone开发很新,并且很难找到我认为是解决这个问题的好方法。

I'm pretty new to iPhone development and have struggled to find what I consider to be a neat way around this problem.

我有一个用户界面,其中一个记录数据摘要显示在导航控制器内的表格中。当用户单击行的附件按钮时,新视图被推到导航控制器上,显示用户可以编辑相应记录中的数据的视图。完成后,编辑视图将从导航控制器的堆栈中弹出,用户将返回到表视图。

I have a user interface where a summary of record data is displayed in a table inside a navigation controller. When the user clicks the accessory button for a row, a new view is pushed onto the navigation controller revealing a view where the user can edit the data in the corresponding record. Once done, the editing view is popped from the navigation controller's stack and the user is returned to the table view.

我的问题是当用户返回到表视图时,该表仍然显示编辑记录之前的数据状态。因此,我必须重新加载表数据以显示更改。

My problem is that when the user returns to the table view, the table still shows the state of the data before the record was edited. I must therefore reload the table data to show the changes.

在显示表数据之前似乎无法重新加载表数据,因为调用仅更新显示的记录。在显示表格之后重新加载它会导致旧数据在用户眼前发生变化,我对此并不满意。

It doesn't seem possible to reload the table data before it is displayed as the call only updates displayed records. Reloading it after the table has been displayed results in the old data changing before the user's eyes, which I'm not too happy with.

这对我来说似乎很漂亮在iPhone应用程序中要做的正常事情。

This seems to me like a pretty normal thing to want to do in an iPhone app.

有人可以建议这样做的最佳实践方法吗?我觉得我错过了什么。

Can anyone please suggest the best practice approach to doing this? I feel like I'm missing something.

干杯 - 史蒂夫。

推荐答案

我将通过以下方式实现此目的:

I'd implement this in the following way:


  1. 保存单击单元格的indexPath。

  1. Save indexPath of a clicked cell.

实现 - 视图控制器的[UIViewController viewWillAppear:] 方法,其中包含UITableView。如果保存的indexPath不是nil,则重新加载指定的单元格:

Implement -[UIViewController viewWillAppear:] method of the view controller, which contains the UITableView. If saved indexPath is not nil, reload specified cells with:

- [UITableView reloadRowsAtIndexPaths:withRowAnimation:]

这篇关于在UINavigationController层次结构中刷新UITableView的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆