首页 > 其他 > 详细

TableView的删除操作

时间:2015-07-21 21:46:57      阅读:133      评论:0      收藏:0      [点我收藏+]

 

 

-(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];

 

}

TableView的删除操作

原文:http://www.cnblogs.com/yuyu-2012/p/4665532.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!