UITableView

2016-02-29  本文已影响71人  奋斗的蜗牛

一. 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];
上一篇 下一篇

猜你喜欢

热点阅读