美文网首页
day10-左滑删除

day10-左滑删除

作者: js_huh | 来源:发表于2020-06-08 01:43 被阅读0次

数据刷新01全局刷新
数据刷新02局部刷新


是什么?

  • UITableViewDataSource 的代理方法.

    /**
     什么情况下,触发此代理?
      在cell中,由右向左滑动到底时,则触发此方法.
      滑动时,出现编辑按钮,点击此编辑按钮,则触发此方法.
     作用: 根据指定的行,实现删除此cell.
     @param tableView 编辑的tableView
     @param editingStyle 单元格编辑样式(如:具有删除编辑控件/具有插入编辑控件)
     @param indexPath 索引路径(指定行)
     */
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
      //根据获取当前行,在集合中删除对应的模型
      [self.wineData removeObjectAtIndex:indexPath.row];
      //删除的局部刷新
      //NSArray *arrayTemp = @[[NSIndexPath indexPathForRow:indexPath.row inSection:0]];
      //[self.tableView deleteRowsAtIndexPaths:arrayTemp withRowAnimation:UITableViewRowAnimationLeft];
      
      [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
    }
    
  • UITableViewDelegate的代理方法

    // 更改cell左滑时,按钮的文字(默认: delete)
    -(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
      return @"删除";
    }
    

相关文章

网友评论

      本文标题:day10-左滑删除

      本文链接:https://www.haomeiwen.com/subject/puosvhtx.html