您的位置:首页 > 产品设计 > UI/UE

UITableView 编辑

2016-01-26 11:07 399 查看
tableView的编辑:cell的添加、删除。
使⽤场景: 删除⼀个下载好的视频,删除联系⼈; 插⼊⼀条新的聊天记录等

编辑:
1、让tableView处于编辑状态
TableView⽅法
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;

2、指定tableView哪些⾏可以编辑
TableView DataSource⽅法
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;

3、指定tableView编辑的样式(添加、删除)
TableView Delegate⽅法
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;

4、编辑完成(先操作数据源,再修改UI)
TableView DataSource⽅法
- (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath: (NSIndexPath *)indexPath;

移动:
1、让tableView处于编辑状态
TableView⽅法
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;

2、指定tableView哪些⾏可以移动
TableView DataSource⽅法
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath: (NSIndexPath *)indexPath;

3、移动完成
TableView DataSource⽅法
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath: (NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

4、监测移动过程,实现限制跨区移动
TableView⽅法
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: