我使用以下代码在用户滑动 tableview
单元格时显示删除按钮。我想在这个按钮中写取消而不是删除,我怎样才能实现这个功能??
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
和
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If you're data source is an NSMutableArray, do this
[self.dataArray removeObjectAtIndex:indexPath.row];
}
}
最佳答案
如果您只想将按钮的标题更改为“取消”,则只需在 TableView 的委托(delegate)中实现 -tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
方法即可。
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Cancel";
}
关于ios - 在 UITableView 中滑动取消而不是删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15161103/