单元格删除方法和交换位置方法

来源:互联网 发布:淘宝客微信群封号 编辑:程序博客网 时间:2024/05/16 01:21

- (NSArray<UITableViewRowAction*> *)tableView:(UITableView*)tableView editActionsForRowAtIndexPath:(NSIndexPath*)indexPath
{
   
UITableViewRowAction *deleteRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDestructivetitle:@"删除"handler:^(UITableViewRowAction* _Nonnull action, NSIndexPath * _Nonnull indexPath) {
       
        [
self.deleteDataremoveObjectAtIndex:indexPath.row];
       
        [
self.tableViewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
       
    }];
   
   
UITableViewRowAction *topRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"置顶"handler:^(UITableViewRowAction* _Nonnull action, NSIndexPath * _Nonnull indexPath) {
       
        [
self.deleteDataexchangeObjectAtIndex:indexPath.rowwithObjectAtIndex:0];
       
       
NSIndexPath *firstIndexPath = [NSIndexPathindexPathForRow:0inSection:indexPath.section];
       
        [tableView
moveRowAtIndexPath:indexPathtoIndexPath:firstIndexPath];
       
       
       
    }];
   
    topRowAction.
backgroundColor= [UIColorblueColor];
   
   
UITableViewRowAction *moreRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleNormaltitle:@"更多"handler:^(UITableViewRowAction* _Nonnull action, NSIndexPath * _Nonnull indexPath) {
       
       
        [
self.tableViewreloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
       
    }];
//    moreRowAction.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
   
return @[deleteRowAction,topRowAction,moreRowAction];
}
0 0
原创粉丝点击