iOS 11的一些兼容问题

2017-10-07  本文已影响4人  我思__故我在

最近用Xcode 9 开发一个页面,创建的UITableViewStyleGrouped类型的tableView,在代理中无论我怎么设置section头尾高度,section之间的高度都不变,目测有44个高度。

调整section之间的高度,依赖于下面的两个代理方法:

- (CGFloat )tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.1;
}
- (CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.1;
}

打断点调用发现 heightForHeaderInSection这个代理没有执行!问了一下度娘,确定了问题:iOS 11默认开启了Self-Sizing,导致该代理没有执行。

解决方法,亲测有效:

//兼容iOS 11需要实现的方法;iOS 11默认开启了Self-Sizing
    if ([OS_VERSON integerValue] > 10) {
        
        self.tableView.estimatedSectionHeaderHeight = 0;
    }
上一篇 下一篇

猜你喜欢

热点阅读