您的位置:首页 > 产品设计 > UI/UE

UITableView 单元格自定义个别不能滑动删除

2016-03-08 20:17 477 查看
//自定义滑动单元格显示按钮名称
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"删除";
}

//这里设置能够滑动和不允许滑动的单元格
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([_testLable.text isEqualToString:@"这行不许删除"]) {
return UITableViewCellEditingStyleNone
}
return UITableViewCellEditingStyleDelete;
}

//执行删除操作
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[_dataArr removeObjectAtIndexPath:indexpath.row];
[_tableView reloadData];
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: