首页 > 其他 > 详细

实现cell显示一个删除button

时间:2017-04-16 16:07:56      阅读:259      评论:0      收藏:0      [点我收藏+]

假设想实现滑动cell时,cell右边就能显示一个删除button,则要实现tableview 下边方法:

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


让一个cell实现滑动出现删除button


我们删除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显示一个删除button

原文:http://www.cnblogs.com/liguangsunls/p/6719004.html

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