码迷,mamicode.com
首页 > 移动开发 > 详细

UI基础:UITableView的编辑和移动

时间:2015-07-18 18:21:59      阅读:131      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!