UI - UITableView 移动
来源:互联网 发布:东莞网络外包公司 编辑:程序博客网 时间:2024/06/03 19:28
//在TableView编辑 篇章中加入/*************************** TableView 的移动 ***************************/#pragma mark--移动第一步: 让tableView处于编辑状态//Table的协议方法- (void)setEditing:(BOOL)editing animated:(BOOL)animated{ //1. [super setEditing:editing animated:animated]; //2. [self.tableView setEditing:editing animated:animated];}#pragma mark--移动第二步: 指定哪行可以移动- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}#pragma mark--移动限制: 限制跨区移动- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath{// sourceIndexPath: 移动之前的位置// proposedDestinationIndexPath: 想去的位置(松手的位置) if (sourceIndexPath.section == proposedDestinationIndexPath.section) { return proposedDestinationIndexPath; } return sourceIndexPath;}#pragma mark--移动第三步: 移动完成- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ //移动不需要删除cell(UI) //1.删除数据源 NSMutableArray *arr1 = [self.dataArr objectAtIndex:sourceIndexPath.section]; NSString *str = [arr1 objectAtIndex:sourceIndexPath.row]; [arr1 removeObjectAtIndex:sourceIndexPath.row]; //2.添加数据 cell移动之后所在的分组 NSMutableArray *arr2 = [self.dataArr objectAtIndex:destinationIndexPath.section]; [arr2 insertObject:str atIndex:destinationIndexPath.row];}
0 0
- UI - UITableView 移动
- 进击的KFC:UI(十)UITableView的编辑和移动
- UI---UITableView
- UI - UITableView
- 爬爬爬之路:UI(十) UITableView(二) UITableView编辑 UITableViewCell移动
- 猫猫学IOS(十四)UI之UITableView扩充_表格的修改_(增删移动)
- AJ学IOS(14)UI之UITableView扩充_表格的修改_(增删移动)
- Swift UI控件 --> UITableView
- UI—UITableView
- UI UITableView表视图
- UI基础—UITableView
- IOS UI UITableView
- iOS笔记UI--UITableView
- UI 第九天 UITableView
- UI基础-UITableView 编辑
- UI基础-UITableView 高级
- iOS UI 07 uitableview
- UI - UITableView 编辑 、TableViewController
- 打印mac地址
- linux下如何使用sftp命令
- Android Butterknife Zelezny
- 测试基础
- iOS代码混淆
- UI - UITableView 移动
- IIS——解决发布后远程调用问题(三)
- 面试笔试 ----- 珠海YY Android (未通过)
- 关于ARGB_8888、ALPHA_8、ARGB_4444、RGB_565的理解
- #沉浸状态栏
- php【基础学习十六】多个构造方法
- JTS(Geometry) 空间数据模型的构建
- linux 调试用到知识点
- jQuery子窗体取得父窗体元素的方法