码迷,mamicode.com
首页 > 其他好文 > 详细

实现cell显示一个删除按钮

时间:2015-07-09 14:33:40      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:cell   删除   tableview   删除cell   uitableview   

如果想实现滑动cell时,cell右边就能显示一个删除按钮,则要实现tableview 下边方法:

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


让一个cell实现滑动出现删除按钮


我们删除cell,一般调用方法

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationTop];


以下边的例子做参考:


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

if (editingStyle == UITableViewCellEditingStyleDelete) {


[self.myArray removeObjectAtIndex:[indexPath row]];//删除数据源对应的内容


[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationTop];//删除列表的显示

}

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

实现cell显示一个删除按钮

标签:cell   删除   tableview   删除cell   uitableview   

原文地址:http://blog.csdn.net/lu_ca/article/details/46815967

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!