UITableView和UITableViewCell的一点使用小总结
2012-06-13 11:54
441 查看
开发一款ipad应用程序,开始接触ios,网上调查了很多信息,非常感谢有那么多网友的帮助。
在这里也把自己用到的总结一下,方便自己和其它网友查询。
自定义UITableViewCell的使用
1:视图中使用多个TableView,设置tag来区分。
2:TableViewCell选中不高亮显示
3:TableViewCell的背景色设置
如果自定义颜色
4:选中高亮背景色设置(黑色)
5:默认选中TableViewCell第一行(section 0, row0)
6:多余的空白Cell不显示
在这里也把自己用到的总结一下,方便自己和其它网友查询。
自定义UITableViewCell的使用
1:视图中使用多个TableView,设置tag来区分。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(tableView.tag == 1 ) { } }
2:TableViewCell选中不高亮显示
cell.selectionStyle = UITableViewCellSelectionStyleNone;
3:TableViewCell的背景色设置
cell.contentView.backgroundColor = [UIColor blackColor];
如果自定义颜色
cell.contentView.backgroundColor = [UIColor colorWithRed:0.898 green:0.898 blue:0.898 alpha:1.0];//#eeeeee
4:选中高亮背景色设置(黑色)
UIView* bgView = [[UIView alloc] init] ; bgView.frame = CGRectMake(10, 5, 140, 30); [bgView setBackgroundColor:[UIColor colorWithWhite:2 alpha:0.2]]; [cell setSelectedBackgroundView:bgView]; cell.selectedBackgroundView.backgroundColor = [UIColor blackColor];
5:默认选中TableViewCell第一行(section 0, row0)
[tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0]; NSIndexPath *ip = [NSIndexPath indexPathForRow:0 inSection:0];//获得选中的第几行
6:多余的空白Cell不显示
tableView.separatorStyle = UITableViewCellSeparatorStyleNone; UIView *v1 =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 155, 1)]; v1.backgroundColor = [UIColor whiteColor]; [tableView setTableFooterView:v1];
相关文章推荐
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- IOS中UITableView使用总结
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- UITableView---iOS开发的常用控件使用总结
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- iOS中UITableView使用总结和 iOS UITableView代理方法详解
- 转 UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- 【IOS 开发学习总结-OC-51】★★★ios开发之UI控件——UITableView 与UITableViewCell
- iOS之UITableView的使用——自定义UITableViewCell
- 使用UITableView的自定义UITableViewCell构建聊天界面
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- UITableView 基本使用方法总结
- iOS开发学习总结——UITableView使用初步
- IOS UITableView 使用总结