UITableView设置section header和footer高度

UITableView设置style为UITableViewStyleGrouped后调用

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

设置高度无效

解决:
先调用代理方法:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
      return [[UIView alloc]init]; 
} 
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
     return [[UIView alloc]init];
}

之后再去设置 section 的 header 和 footer 高度即可生效。

你可能感兴趣的:(UITableView设置section header和footer高度)