标签:
最近自己使用了UITableView写了一个通讯录,但是在编写过程还算顺利,但是后来测试的时候,发现在iOS8中TableView的分区头不能正常显示,使用
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
方法可以正常的设置分区的Title,但是如果你使用了
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
设置了分区的sectionHeaderView,那么你会发现在iOS8之前的系统中可以正常的现实分区的头部视图,而从iOS8开始只设置此方法是无法显示头部视图的,所以你需要在配合着下面方法,为TableView设置分区视图的高度
- (CGFloat)tableView:(UITableView * )tableView heightForHeaderInSection:(NSInteger)section;
另外,如果代码中设置了titleForHeaderInSection,则不需要上面的设置也可以正常显示。 但是只会显示出title的高度大小的分区头视图
ios8 如果UITableView只设置viewForHeaderInSection,则可能section不能显示,iOS7及以下版本显示正常。 解决方案: 设置heightForHeaderInSection。 - (CGFloat)tableView:(UITableView * )tableView heightForHeaderInSect
http://www.lxway.com/1232078.html
iOS8中 UITableView section 分区头部视图不显示
标签:
原文地址:http://www.cnblogs.com/menglingxu/p/5630995.html