IOS UITableViewUITableView小技巧--实现cell向左滑动删除,编辑等功能

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
} - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
DSLog(@"点击了删除");
}];
UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
DSLog(@"点击了编辑");
}];
editAction.backgroundColor = [UIColor grayColor];
return @[deleteAction, editAction];
} - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
editingStyle = UITableViewCellEditingStyleDelete;
}

  

上一篇:Mysql查询语句中字符型字段不区分大小写解决方法


下一篇:微信小程序动态显示项目倒计时效果