在 iPhone 上有一个教科书示例,说明如何在消息应用程序中删除表格 View 行。 这似乎使用三个独立的 View 来执行任务。
我的问题是关于是否有捷径可以实现这一目标,或者您是否只创建三个屏幕并做到这一点显而易见。
非常感谢。
最佳答案
从 Storyboard 中删除一行非常简单。您只需在 TableView 数据源中继承 2 个方法。首先是判断是否可以删除一行:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
其次是从 TableView 中删除行:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
关于iOS7 Tableview删除行最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21073247/