自定义删除单元格

来源:互联网 发布:电子工程师软件 编辑:程序博客网 时间:2024/06/05 07:17
#pragma mark  自定义左滑显示编辑按钮
// 自定义左滑显示编辑按钮
-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewRowAction * rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:NSLocalizedString(@"删除", nil) handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        
        NSLog(@"删除第%d行",indexPath.row);
        [[Common CommonInstance].allDefenceNewsRecord removeObjectAtIndex:indexPath.row];
        _newsArr = [DevWarningViewModel getTheUsefulDefenceWarningArr];
        [self.myTableView reloadData];
        [SVProgressHUD showSuccessWithStatus:@"删除成功"];
        SVProgressHUD.minimumDismissTimeInterval = 0.1;
        
        /*本地路径*/
        NSString *filePath = [NSString stringWithFormat: @"%@/%@/defenceNewsRecord.text", DOCUMENTDIRECTORY, appDelegate.account.access_uid];
        
        [[Common CommonInstance].allDefenceNewsRecord writeToFile:filePath atomically:YES];


    }];
    
    rowAction.backgroundColor = [[Common CommonInstance]colorFromHexString:@"61b0ce"];
    NSArray *arr = @[rowAction];
    return arr;
}
0 0
原创粉丝点击