快速解决侧滑删除按钮的示例

快速解决侧滑删除按钮的示例

tableView

删除按钮示例.gif

懒加载数据

-(NSMutableArray *)array_Contast{
if (!_array_Contast) {
    
    _array_Contast = [NSMutableArray new];
}

return  _array_Contast;
}

设置tableView为可编辑状态

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

[self.array_Contast removeObjectAtIndex:indexPath.row];

删除某一行

[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

记住删除后,一定要归档一次

[NSKeyedArchiver archiveRootObject:self.array_Contast toFile:kFilePath];    
}

-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{

return @"删除";
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容