• TableView的删除操作


     

     

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

        

        if (editingStyle != UITableViewCellEditingStyleDelete) return;//非编辑删除模式

        //先修改模型中的数据

        [persons removeObjectAtIndex:indexPath.row];

     

        //刷新表格

    //下面的方法必须是模型里的行数和tableView中的行数必须一致

    //    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];

        

        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];

        

    }

     

     

     

    - (IBAction)remove:(UIBarButtonItem *)sender {

        

        //进入编辑模式

        BOOL result = !self.tableView.isEditing;

        [self.tableView setEditing:result animated:YES];

     

    }

  • 相关阅读:
    CentOS7安装部署Mongodb
    Innodb
    flatstyle实现图片贴图
    通过Rdp实现连接远程桌面
    EverythingSdk
    亿企代账
    http文件下载服务器
    亿企代账2
    通过bcp快速导入、导出sqlserver数据
    delphi7设置日期格式
  • 原文地址:https://www.cnblogs.com/yuyu-2012/p/4665532.html
Copyright © 2020-2023  润新知