隐藏TableViewHeaderView所以我有这个泰伯维有几节,(3)要准确。我希望这是对第2和第3,而不是第一部分头..特定的TableView部分
我所做的继承人什么:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionName;
UIView *tempView;
tempView = [[UIView alloc]initWithFrame:CGRectMake(0,0,300,20)];
tempView.backgroundColor=[UIColor grayColor];
UILabel *tempLabel = [[UILabel alloc]initWithFrame:CGRectMake(10,0,300,20)];
tempLabel.backgroundColor = [UIColor clearColor];
tempLabel.shadowColor = [UIColor blackColor];
tempLabel.shadowOffset = CGSizeMake(0,2);
tempLabel.textColor = [UIColor whiteColor]; //here you can change the text color of header.
tempLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0f];
switch (section)
{
break;
case 1:
{
sectionName = NSLocalizedString(@"Information", @"Information");
tempLabel.text = sectionName;
[tempView addSubview:tempLabel];
}
break;
case 2:
{
sectionName = NSLocalizedString(@"Tools", @"Tools");
tempLabel.text = sectionName;
[tempView addSubview:tempLabel];
}
break;
}
return tempView;
}
我就需要做什么困惑...继承人一个图片是怎么回事:
是的,你也应该为'的tableView返回0:heightForHeaderInSection:',但它是最好的,如果你还修改了'viewForHeaderInSection'到的情况下返回'nil'该部分== 0,待办事项它在该方法的顶部。 –
你认为你可以为我实现部分== 0的情况?我实现了viewForHeaderInSection方法像这样,开关(部分) { 情况下0: { tableView.tableHeaderView =零; } break;它没有工作:( – jsetting32
只需添加这是该方法的第一行:'如果(部分== 0)返回零;'如果你这样做,你不会需要一个'情况0'(和也。 ,你不会有创建一个标题视图的开销,你最终会放弃)。 –