UITableView 相关属性的设置

来源:互联网 发布:我的世界ip地址和端口 编辑:程序博客网 时间:2024/05/01 20:42

1.获取tableview中的cell

/*1.定义cell高度时,获取cell的方法*///ContentTVCell 自己自定义的cell//jokeTableview UITableView 对象ContentTVCell *cell=(ContentTVCell*)[self tableView:self.jokeTableView cellForRowAtIndexPath:indexPath];/*2.获取选中的cell*///获取选中的cell的indexPath NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];/*3.刷新某一个section*///刷新tableview的某一个sectionNSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:1];[self.baseTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];

2. cell的选中状态

//取消cell的选中状态 self.selectionStyle = UITableViewCellSelectionStyleNone;/*自定义UITableViewCell选中后的背景颜色和背景图片*/UIColor* color=[[UIColor alloc]initWithRed:0.0 green:0.0 blue:0.0 alpha:1];//通过RGB来定义颜色 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease];cell.selectedBackgroundView.backgroundColor=[UIColor   ***]或color;//自定义选中后的背景图片cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"123.png"]]autorelease];//设置UITableViewCell中的字体颜色时用cell.textLabel.highlightedTextColor=[UIColor **color];

3.隐藏UITableViewCell的分隔线

[chatTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];/* // UITableViewCellSeparatorStyle有如下几种 typedef enum {   UITableViewCellSeparatorStyleNone,   UITableViewCellSeparatorStyleSingleLine,   UITableViewCellSeparatorStyleSingleLineEtched} UITableViewCellSeparatorStyle;*/

4.定义UITableViewCell的样式

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;/*accessoryType有如下几种typedef enum {   UITableViewCellAccessoryNone,   UITableViewCellAccessoryDisclosureIndicator,   UITableViewCellAccessoryDetailDisclosureButton,   UITableViewCellAccessoryCheckmark} UITableViewCellAccessoryType;*/
1 0