aro*_*ooo 1 objective-c uitableview ios
我的UITableView中有2个部分.我希望我的第一个标题是不存在,没有空间,没有任何东西.第一个单元格触摸屏幕顶部.我想要第二部分的自定义部分标题.
如果我不使用,我可以这样做,- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section但在我使用此方法的那一刻,第一部分中出现空白标题视图.我究竟做错了什么?
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (!section == 0){
UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30.0f)];
UILabel *label = [[UILabel alloc]initWithFrame:[header frame]];
[label setText:@"Test Header"];
[header addSubview:label];
return header;
}
else{
// This apparently causes a header to appear in section 0.
// Without this entire method it works fine- but it means I can't customize
// the header.
return nil;
}
}
Run Code Online (Sandbox Code Playgroud)
寻找
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
的方法UITableView.
你可以return 0;在第一部分.