2010-08-20 60 views
1

我有一个iPhone应用程序,有一个用户喜好页面,用户可以重新排列uitableview行,就像iPhone内置在天气预报应用程序的设置页面一样。现在我的问题是在用户完成重新排列之后,我需要按重新安排的顺序将数据保存在数据库中。但是我无法从uitableview中读取数据。重新排列Uitableview行

如何从uitableview中读取重新排列的数据?

提前寻找您的宝贵回应

感谢

喜悦

回答

3

你不会在编辑的阅读正文之后的rearraged顺序,UITableView的告诉它的DataSource的是什么,而编辑而改变发生。它使用以下消息:

- (void)tableView:(UITableView *)tableView 
     commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
     forRowAtIndexPath:(NSIndexPath *)indexPath; 

- (void)tableView:(UITableView *)tableView 
     moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
     toIndexPath:(NSIndexPath *)toIndexPath; 

您将实现数据源,以便它记录此更改并在编辑完成时存储它们。

另一个不推荐的方法是使用

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath; 

您的tableView细胞的然后dataEntity由该单元表示弄清楚枚举,并重建基础数据。

最后一种方法只是为了完整性,请使用第一种。