tableview cell的移动
来源:互联网 发布:古剑奇谭ol激活码淘宝 编辑:程序博客网 时间:2024/04/30 16:44
- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib. array1= [[NSMutableArray alloc]initWithObjects:@"1",@"3", @"5",@"7", @"9",@"11", nil]; array2 =[[NSMutableArray alloc]initWithObjects:@"2",@"4", @"6",@"8", nil]; [tableview setEditing:YES animated:YES];//移动 要设置可编辑}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0) { return [array1 count]; }else { return [array2 count]; } return 0;}-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ if (section ==1) { return @"更多"; } return @"";}-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell * cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identifier"]; if (indexPath.section ==0) { cell.textLabel.text = [array1 objectAtIndex:indexPath.row]; }else if (indexPath.section ==1) { cell.textLabel.text = [array2 objectAtIndex:indexPath.row]; } return cell;}#pragma mark 决定tableview的编辑模式- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleNone;}-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}//移动的时候改变数据源-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ if ([sourceIndexPath section]==[destinationIndexPath section]) { if ([sourceIndexPath section]==0) { NSString * source =[array1 objectAtIndex:sourceIndexPath.row]; [array1 removeObjectAtIndex:sourceIndexPath.row]; [array1 insertObject:source atIndex:destinationIndexPath.row]; }else if ([sourceIndexPath section]==1) { NSString * source =[array2 objectAtIndex:sourceIndexPath.row]; [array2 removeObjectAtIndex:sourceIndexPath.row]; [array2 insertObject:source atIndex:destinationIndexPath.row]; } }else { NSString * source =[array1 objectAtIndex:sourceIndexPath.row]; NSString * destination =[array2 objectAtIndex:destinationIndexPath.row]; [array1 replaceObjectAtIndex:[sourceIndexPath row] withObject:destination]; [array2 replaceObjectAtIndex:[destinationIndexPath row] withObject:source]; } NSLog(@"array1======%@\n array2==%@",array1,array2);}
0 0
- tableview cell的移动
- Cell特效之图片随着TableView的滑动上下移动
- tableview 自动移动到某个cell
- 点击tableView的cell弹出tableView
- TableView的Cell的重用
- ios的tableview的cell
- tableview中cell的设置
- tableview中cell的设置
- ios自制tableview的cell
- 设置tableview的cell颜色
- tableView 的cell自适应高度
- ios自制tableview的cell
- tableView的新cell方法
- tableView以及cell的使用
- tableview注册cell的目的
- tableView cell 的刷新 插入
- tableView 的cell功能操作方法
- tableView 的cell功能操作方法
- 买房黑幕大爆光,见招拆招,谨防陷阱
- mysql union 用法
- 盗版XP成主要恶意攻击对象
- android Toast显示消息的几种方法
- oracle 11g exp导出空表
- tableview cell的移动
- Oracle Transportable TableSpace(TTS) 传输表空间 说明
- 线索二叉树的建立及遍历
- 解决tomcat在大进行大并发请求时,出现内存溢出的问题
- nyist.acm喷水装置(一) 时间限制:3000 ms | 内存限制:65535 KB 难度:3
- Oracle和Vertica中构造日历数据
- 你所不知道的Java序列化
- 在驱动模块初始化函数中实现设备节点的自动创建
- UML中的用例图和类图