iOS tableView 自定义表头时,出现的两个问题

    tableView 自定义表头,在下列方法中实现,根据tableView的style而定,如果style为group时,表头将不会悬停,为plain时,表头将悬停;

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;

   为group时,如果设置了表头,那么表尾会有一个默认的高度,会看到第一个表头正常,但是第二个Section的时候,多出了一部分内容。如下图:

    

    

    这个时候,需要同时也设置一下,表尾,在以下方法中,把高度设置为0.01,不能设置为0,为0不起作用。

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

     所以当你需要设置表头,style为plain时,表头将悬停,显示正常。style为group是,表头将不悬停,但是需要把表尾去掉,才能显示正常



猜你喜欢

转载自blog.csdn.net/qq_28699375/article/details/79991104
今日推荐