美文网首页
iOS 11的一些兼容问题

iOS 11的一些兼容问题

作者: 我思__故我在 | 来源:发表于2017-10-07 16:57 被阅读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;
    }

相关文章

网友评论

      本文标题:iOS 11的一些兼容问题

      本文链接:https://www.haomeiwen.com/subject/ntwjyxtx.html