我添加了滑动以通过实现
删除表格单元格的可选性- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Perform the real delete action here. Note: you may need to check editing style
// if you do not perform delete only.
NSLog(@"Deleted row.");
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
这导致我的表格加载方式使得删除按钮立即显示在左侧。我只想要一个滑动删除选项,我不希望在表首次加载时显示任何删除按钮。我需要改变什么?
答案 0 :(得分:0)
删除第二个函数(editingStyleForRowAtIndexPath),并将第一个函数更改为下面的函数:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
}
}