12 UITableView编辑和移动 、UITableViewController、(+UIDatePicker)
来源:互联网 发布:java boolean 安卓 编辑:程序博客网 时间:2024/06/10 20:15
1、UITableView编辑
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;
2、UITableView移动
移动步骤:
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
3、UITableViewController
UITableViewController继承自UIViewController,自带一个tableView
self.view不是UIView而是UITableView
datasource和delegate默认都是self(UITableViewController)
开发中只需要建立UITableViewController子类
4、UIDatePicker
见代码
总结
无论编辑还是移动,都先让tableView进入编辑状态。
编辑结束或者移动结束,要先修改数组或字典中的数据,在更改UI。
UITableViewController是封装好了各种delegate和datasource,能提高我们开发速度。
0 0
- 12 UITableView编辑和移动 、UITableViewController、(+UIDatePicker)
- UIday1001:UITableView 2 编辑(添加、删除)、移动、UITableViewController
- iOS个人整理19-UITableViewController和UITableView的编辑
- UIViewController+UITableView 和 UITableViewController
- UITableView 编辑(增删移动)
- ios开发 UITableViewController和 UITableView
- UITableView(二编辑移动)
- 第十章——UITableView 和 UITableViewController
- 进击的KFC:UI(十)UITableView的编辑和移动
- UITableViewController及UITableView
- iOS基础--UITableView,UITableViewController
- IOS--UITableViewController及UITableView
- 第八章 UITableView UITableViewController
- UITableView UITableViewCell UITableViewController
- UITableVew使用一(UITableView和UITableViewController的使用注意)
- iOS Programming 学习笔记 - 03 UITableView和UITableViewController
- UIDatePicker 控件获取本地时间 和 UIDatePicker的移出移回(简单的动画移动效果)
- UI一揽子计划 10 (UITableView 中cell 的编辑, 增加, 删除、UITableViewController 、)
- 《C语言及程序设计初步》第四讲实践项目
- 为什么在linux的命令行中cd .. 能返回上层目录
- ubuntu14.04中安装opencv2.4.9
- 以mysql为数据源的Solr配置
- <LeetCode OJ> 303. Range Sum Query - Immutable
- 12 UITableView编辑和移动 、UITableViewController、(+UIDatePicker)
- [LeetCode]Text Justification
- C# DataGridView 与 DataSet
- iOS关于百度地图坐标转换问题
- 虚拟化三剑客专题-XenServer(上)
- iOS关于上传单张及多张图片
- 被忽视和默认的“全概率”导出贝叶斯公式的鼻祖
- CocoaPods安装和使用
- 【Android开发—电商系列】(三):缓存的使用