美文网首页
更新iOS11后 UITableView适配问题

更新iOS11后 UITableView适配问题

作者: wxkkkkk | 来源:发表于2017-09-29 16:25 被阅读0次

更新系统后项目页面出现了UITableView显示错位的两个问题

  • UITableView的顶部留白问题
  • UITableView的section上下空隙多出问题

1.UITableView的顶部留白

iOS11下有问题的顶部


iOS11有问题.png

解决方法 去掉系统默认设置的边距

if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

解决后顶部留白消失


iOS11.png

2.UITableView显示多个Section 每个Section上下多出空隙

iOS11系统下 当UITableView初始化的style为UITableViewStyleGrouped时,显示多个Section会出现多余空隙

解决方法是把系统自带的上下view设置为nil

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

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

先写这两点 后续开发碰到在一一总结

相关文章

网友评论

      本文标题:更新iOS11后 UITableView适配问题

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