UITabBarController中的UITableViewController = iOS 11上不需要的填充

时间:2018-03-02 16:19:51

标签: uitableview uitabbarcontroller padding ios11

我需要一个托管UITableViewControllers的UITabBarController。我的控制器以这种方式组织:

  • 的UITabBarController
    • 选项卡1的UINavigationController
      • UITableViewController for tab 1
    • 选项卡2的UINavigationController
      • UITableViewController for tab 2
    • 标签3的UINavigationController
      • UITableViewController for tab 3

我的故事板的屏幕截图:

enter image description here

适用于iOS 8,9& 10.在iOS 9上:

enter image description here

但是在iOS 11上,我在表格视图的顶部有一个额外的填充:

enter image description here

如何解决这个问题?我已经尝试在StackOverflow上提出的每一个解决方案都没有成功,它总是可以在iOS 8,9& 10或者在iOS 11上。在将Xcode从9.1更新到9.2之前,我几乎肯定它在今天早上在所有平台上工作:@ ...

1 个答案:

答案 0 :(得分:0)

这似乎是在使用Xcode 9.2创建的项目中出现的错误。你应该:

  • 关闭表格视图导航栏的半透明度
  • 以不同的iOS版本覆盖标题的高度:

    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        if #available(iOS 11, *) {
            return CGFloat.leastNormalMagnitude
        }
        return 0
    }