【问题标题】:Extra space between NavigationBar and TableViewNavigationBar 和 TableView 之间的额外空间
【发布时间】:2022-01-10 03:44:13
【问题描述】:

在最新的 iOS 13 版本中获取导航栏和表格视图之间的空间?尝试了很多解决方案。没运气?请帮助我。 尝试以下解决方案

1.

scrollView.contentInsetAdjustmentBehavior = .automatic

2.

if #available(iOS 11.0, *) {

            tblView.contentInsetAdjustmentBehavior = .never
        } else {
            automaticallyAdjustsScrollViewInsets = false
        }
}

3.

overrideUserInterfaceStyle = .dark 

4.

yourtableView.tableHeaderView?.removeFromSuperview()

yourtableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))

yourtableView.layoutIfNeeded()

【问题讨论】:

  • 这个问题只出现在 iOS 13 上吗?你试过在 iOS 12 上模拟它吗?

标签: swift tableview navigationbar spacing ios13


【解决方案1】:

确保两件事:

1.

self.automaticallyAdjustsScrollViewInsets = NO

2。 从属性检查器,使 style = plain

【讨论】:

    【解决方案2】:

    这是 iOS 15 中唯一对我有用的解决方案:

    if #available(iOS 15.0, *) {
        tableView.sectionHeaderTopPadding = 0
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多