iOS —— UITableView 常用API
来源:互联网 发布:java大视频断点续传 编辑:程序博客网 时间:2024/05/22 12:37
COMMAND+SHIFT+0 API分享
单元格常用属性:
accessoryType 右侧小按钮样式backgroundColor 单元格背景颜色textLabel.text 单元格显示内容detailTextLabel.text 单元格副标题(如果UITableViewCellStyleDefault的时候,不显示detailTextLabel)detailTextLabel.textColor 副标题颜色imageView.image 添加图片(只读)contentView 自定义添加单元格内容cell.textLabel.highlightedTextColor 单元格选中状态的字体颜色
//设置行高 table.rowHeight = 40; //设置表格线的样式 table.separatorStyle=UITableViewCellSeparatorStyleSingleLine; //设置表格线的颜色 table.separatorColor = [UIColor redColor];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifier = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; } cell.textLabel.text = [[[app.mDataList objectAtIndex:indexPath.row] componentsSeparatedByString:@","] objectAtIndex:0]; cell.detailTextLabel.text = [[[app.mDataList objectAtIndex:indexPath.row] componentsSeparatedByString:@","] objectAtIndex:1]; return cell;}-(void)edit{ BOOL isEdition = !self.mTableView.editing; [self.mTableView setEditing:isEdition];}-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewCellEditingStyleDelete|UITableViewCellEditingStyleInsert;}-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}
//移动row时调用方法-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ if(sourceIndexPath!=destinationIndexPath){ id object = [app.mDataList objectAtIndex:sourceIndexPath.row]; [object retain]; [app.mDataList removeObjectAtIndex:sourceIndexPath.row]; if (sourceIndexPath.row>app.mDataList.count) { [app.mDataList addObject:object]; }else{ [app.mDataList insertObject:object atIndex:destinationIndexPath.row]; } }}-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ //数据处理 [app.mDataList removeObject:[self.mDeletedList objectAtIndex:indexPath.row]];}
//判断点击row的方式是否是编辑模式-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if (tableView.editing == NO) { NextViewController *nextVC = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil]; nextVC.delegate = self; [self.navigationController pushViewController:nextVC animated:YES]; }else{//数据处理 [self.mDeletedList addObject:[app.mDataList objectAtIndex:indexPath.row]]; }}
//编辑模式下,删除按钮所调方法-(void)finishDelete{ [app.mDataList removeObjectsInArray:self.mDeletedList]; [self.mTableView reloadData]; self.mTableView.editing = NO;} //滑动删除-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];}
//当TableView将要呈现的时-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:YES]; [self.mTableView reloadData];}
//row高度- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row==0) { return tableView.rowHeight; }else{ return tableView.rowHeight*2; }}- (NSArray*)sectionIndexTitlesForTableView:(UITableView *)tableView{ return ABC;}
//自定义TableVIew 内容 static NSString *cellIdetifier = @"mycell"; myCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdetifier]; if(cell==nil){ cell = [[[NSBundle mainBundle] loadNibNamed:@"myCell" owner:self options:nil] lastObject]; }
0 0
- iOS —— UITableView 常用API
- iOS开发之高级视图—— UITableView常用方法
- iOS——UITableView
- iOS——UITableView
- iOS开发 UITableView 常用细节
- iOS开发 UITableView 常用细节
- iOS开发 UITableView 常用细节
- iOS开发 UITableView 常用细节
- iOS UITableView 常用方法集合
- ios开发笔记(二)—— UITableView的常用用法
- iOS开发学习笔记——UITableview
- IOS系列——UITableview晋级篇
- IOS学习笔记——UITableView(一)
- IOS学习笔记——UITableView (二)
- IOS学习笔记——UITableView(三)
- UITableView的基础知识——IOS
- iOS控件——UITableView详解
- iOS UITableView简介 —— HERO博客
- Atom介绍和安装步骤
- 背包
- 背包问题的转化
- next_permutation 实现
- 1.guake终端ubuntu;2. Ubuntu 数据库中文问题;3.状态记录
- iOS —— UITableView 常用API
- 递归—北大POJ 1664 放苹果(集合划分系列,还需再看)
- Android使用UncaughtExceptionHandler捕获全局异常
- 裘宗燕:C/C++ 语言中的表达式求值
- 安装linux与分区
- 全新万能PDF转换器官方免费下载
- Android状态系统——View状态设计
- ext 在线中文api
- HDU 1505 City Game