2016-12-13 108 views
0

我加入刷卡通过实施删除按钮显示在表格视图单元格用户刷删除

- (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; 
} 

这是导致我的表加载以这样的方式,一个删除按钮来删除可选性的表视图单元格之前立即显示在左侧。我只想要一个滑动删除选项,我不希望在第一次加载表格时显示任何删除按钮。我需要改变什么?

enter image description here

+0

http://stackoverflow.com/a/3309737/192976的 – Hons

+0

可能的复制[UITableViewCell,在刷卡上显示删除按钮](http://stackoverflow.com/questions/3309484/uitableviewcell-show-delete-button-on-swipe) –

回答

0

卸下第二函数(editingStyleForRowAtIndexPath),并改变第一个到下面的一个:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
     if (editingStyle == UITableViewCellEditingStyleDelete) { 
      //add code here for when you hit delete 
     }  
    }