一. UITableView设置组与组之间的间距
设置组的头高度和尾高度
self.tableView.sectionHeaderHeight= 5;
self.tableView.sectionFooterHeight= 0;
二.UITableView设置背景颜色
在groub(组)类型的tableview,tableView会被盖上一层backgroundView(一条条斜线的View),这时候设置backgroundColor会没用的,只能先清空backgroundView,然后才能设置tableview的背景颜色
默认样式是没有backgroundView的。
self.tableView.backgroundView= nil;
self.tableView.backgroundColor= [UIColorcolorWithRed:230/ 250.0green:230/ 250.0blue:230/ 250.0alpha:1];
三. 设置tableviewcell不让选中
cell.userInteractionEnabled = NO;
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
四. UITableView编辑(Editing)模式下:
- 设置某一行是否编辑代理方法
(很实用,工作中遇到的问题,记录一下)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath * indexP =[NSIndexPath indexPathForRow:0 inSection:0];
if (indexP == indexPath) {
return NO;
}
return YES;
}
- 默认选中某一行
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionTop];
[self tableView:tableView didSelectRowAtIndexPath:indexPath];