iOS11的tableView是要坑死人

封装了一个tableView,添加了MJRefresh,然后就发现上拉加载无限加载,endRefreshing根本不管用...

一、先说解决办法,三行代码:
你封装的tableView里面添加
self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;
即可。

如果上面三行不行,那么再来几行。。。

  • (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01;
    }

  • (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
    }

  • (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
    }

  • (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
    }
    Apple的建议一直是heightForFooterInSection和viewForFooterInSection要成对出现,之前的代码也因为不规范地只写了heightForFooterInSection,导致了iOS11会造成tableview下一些UI展示偏移。就像添加通知和移除通知一样,有些API还是规范去实现比较好。

二、原因
iOS11更新以后,估计是为了适配iPhone X的头帘,把视图的安全区域给改变了,具体的原理和适配方案请参考:
http://www.jianshu.com/p/efbc8619d56b

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容