美文网首页
iOS11的tableView是要坑死人

iOS11的tableView是要坑死人

作者: LuffyYa | 来源:发表于2017-10-10 22:28 被阅读30次

封装了一个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

相关文章

网友评论

      本文标题:iOS11的tableView是要坑死人

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