zoukankan      html  css  js  c++  java
  • 滑动删除

    // 实现滑动删除

    // 什么时候调用

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

    {

     

        // 创建 indexpath

        //    NSIndexPath* index = [NSIndexPath indexPathForRow:2 inSection:0];

     

        [self.contacts removeObjectAtIndex:indexPath.row];

        //    [self.contacts removeObjectAtIndex:index.row];

     

        NSLog(@"%@", indexPath);

     

        // 删除模型

        //    [self.contacts removeObject:self.contacts[indexPath.row]];

     

        // 1.reload data

        //    [self.tableView reloadData];

        // 2.删除一行

     

        // 执行的前提条件: 先删除模型

        // self.tableview 里面有个数组专门来记录 当前cell有多少个.

        // 判断和你的模型数组 是不是数量一致

        // 如果和模型数组不一致 直接报错

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

     

        //    for (int i = 0; i < self.contacts.count; i++) {

        //        NSLog(@"%@",[self.contacts[i] name]);

        //    }

     

        [NSKeyedArchiver archiveRootObject:self.contacts toFile:kContactsFilePath];

    }

     

    // 改变滑动删除出来的文字

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

    {

        return @"删除";

    }

  • 相关阅读:
    查看pip install *.whl 支持的文件版本
    spark Infinate 的处理
    nc 文件的nan识别
    mysql 存中文失败问题
    tensorflow 安装
    数据库存含中文的json 时避免存成中文的ascii
    python 继承中的__init__
    python mysql数据库中 json的存储
    python 版本配置问题
    python dict 实现swich
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5669945.html
Copyright © 2011-2022 走看看