1、TableView头视图不随视图移动,头视图出现错位
images/loading.gif' data-original="cid:ba2729a587cfa202c30cf26b78232d24" width="288" data-en-img-selected="true" />
错误原因:tableView的 UITableViewStyle 没有明确的声明
解决方法:在tableView声明的时候明确为 UITableViewStyleGrouped
2、分组表视图顶部空白高度调整
实现方式:
方式一(推荐使用):
Swift:
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { if section == 0 { return CGFloat.min } return tableView.sectionHeaderHeight}
Obj-C:
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 0) return CGFLOAT_MIN; return tableView.sectionHeaderHeight;}
方式二:
In the loadView
_tableView.sectionHeaderHeight = 0;
Then
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0;}
方式三:
- (void)viewWillAppear:(BOOL)animated{ CGRect frame = self.tableView.tableHeaderView.frame; frame.size.height = 1; UIView *headerView = [[UIView alloc] initWithFrame:frame]; [self.tableView setTableHeaderView:headerView];}
原标题:【原】tableView的常见BUG
关键词:ie