仅在使用 Xcode9 和 iOS 11 设备编译时发生。
部分标题不会自动粘在顶部,在视图中留下一个可以看到内容的空间。(包括屏幕截图)点击全屏时发生。但有时标题会在点击操作上粘在顶部 在
向上/向下滚动时,标题会粘在顶部。(包括 GIF)
如果我错了,请纠正我,部分标题的浮动性质由 UITableViewStyle 设置为普通提供。
tableView = UITableView()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
tableView.cellLayoutMarginsFollowReadableWidth = false
tableView = UITableView(frame: self.view.frame, style: UITableViewStyle.plain)
tableView.sectionHeaderHeight = 44
// tableView.estimatedSectionHeaderHeight = 0
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "content")
tableView.register(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: "hContent")
tableView.dataSource = self
tableView.delegate = self
尝试按照此处的建议将estimatedSectionHeaderHeight 设置为0(禁用它) 。但它没有用。
我们尝试按照此处针对类似问题的建议在我们的 hideNavBar 函数中重新加载 tableView 数据。但这会将我们滚动到其他内容。
按照我们 hideNavBar 函数中其他答案的建议尝试了以下操作,并再次面临我们滚动到一些遥远内容的相同问题。
tableView.reloadData()
tableView.layoutIfNeeded()
tableView.beginUpdates()
tableView.endUpdates()