iphone - 在 TableView 中重新排序单元格时获取索引路径?

标签 iphone ios objective-c uitableview

我想更改表格 View 中的单元格顺序

我正在使用以下代码

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath  
{    
    [tableView moveRowAtIndexPath:path1 toIndexPath:path2];
}

这里 path1 用户现在选择的行的索引路径我想找到用户删除该单元格的行的索引路径,所以我怎样才能找到 toIndexPath(path2)。

最佳答案

我认为您对这个方法的用途感到困惑 - 这是 UITableViewDataSource 的回调函数,旨在通知数据模型表中的更改。来自文档:

Tells the data source to move a row at a specific location in the table view to another location.

The UITableView object sends this message to the data source when the user presses the reorder control in fromRow.

这意味着您在这里需要做的是确保您的模型(通常是数组)重新排列以与这些更改正确同步。

希望这能给你一个好的方向。

关于iphone - 在 TableView 中重新排序单元格时获取索引路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14584563/

相关文章:

ios - Swift - 如何将输入数据保存到 Core Data 中?

iphone - 当我打开通知托盘查看通知时 UILocalNotification 触发

iphone - 动画火柴人

objective-c - 将 NSTableView 和 NSArrayController 绑定(bind)在一起

iphone - NSUserDefaults 未写入磁盘

ios - 使用 swift 从应用程序 ios 的缓存中读取图像

iPhone sdk 以编程方式读取崩溃文件?

objective-c - 已删除 NSManagedObject 从 TableView 中正确删除,然后在保存时重新出现

iphone - 什么是运行循环?

iphone - 向下滚动时在 HTML5 移动应用程序 (PhoneGap) 中制作动画图像,例如 Google Plus iPhone 应用程序?