首页 > 移动平台 > 详细

UI基础:UITableView的编辑和移动

时间:2015-07-18 18:21:21      阅读:153      评论:0      收藏:0      [点我收藏+]

相对UITableViiew进行编辑,必须设置代理UITableViewDataSource和UITableViewDelegate.因为需要它们为UITableViiew实现几个必须的方法.

UITableView的编辑和移动都遵循四步操作:

1.让tableView处于可编辑状态(UIViewController中的方法)

2.设置哪些行可以编辑(UITableViewDataSource中的方法)

3.设置编辑的样式(UITableViewDelegate中的方法)

4.提交编辑(a.修改数据源 b.修改界面)(UITableViewDataSource)

 

设置tableVIew处于可编辑状态

-(void)setEditing:(BOOL)editing animated:(BOOL)animated;

设置tableView那哪些行可以编辑

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;

指定编辑样式

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;

提交编辑结果,这个方法在点击done时触发

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

 

在最后一步中,需要实现两个功能:1.修改数据源2.更新界面

 

UI基础:UITableView的编辑和移动

原文:http://www.cnblogs.com/shaoting/p/4657271.html

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