我正在研究 iPhone 编程的书说我可以同时混合使用 UITableViewCellEditingStyle-Insert/Delete。但我不知道该怎么做。有一个 UITableViewdataSource 方法返回类型是 UITableViewCellEditingStyle。但是如果我只能返回一件事(插入或删除),如何同时返回两种样式。
最佳答案
如果我理解正确,您希望通过删除和添加新单元格(以及可选地为该更改设置动画)来更新表格 View 。您需要将调用嵌套在 beginUpdates block 内:
[tableView beginUpdates]
[tableView deleteRowsAtIndexPaths...
[tableView insertRowsAtIndexPaths...
[tableView commitUpdates]
您需要确保您的 UITableViewDataSourceDelegate 方法在调用 commitUpdates:
时反射(reflect)该更改。
关于iphone - UITableViewCellEditingStyle 同时插入和删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6105797/