UITATIONVIEW:截面标题不会自动调整全屏上的位置



仅在用xcode9和ios 11设备编译时才会发生。

截面标头不会自动粘在顶部,在可以看到内容的视图中留出一个空间。(包括屏幕快照(当窃听全屏时发生。但是有时候,标头粘在Tap Action的顶部
向上滚动/向下滚动时,标头粘到顶部。(包括GIF(

屏幕截图

gif

如果我错了,请纠正我,截面标题的浮动性质由UitaiteViewStyle设置为平原。

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

试图将估计的heaheight设置为0(禁用它(,如下所示。但这无效。

,我们尝试在此处建议的类似问题中建议您在Hidenavbar Func中重新加载TableView数据。但这会滚动我们到其他内容。

在我们的hidenavbar功能中其他答案所建议的以下内容尝试了以下内容,并再次面对相同的问题,我们滚动到某些遥远的内容。

tableView.reloadData()
tableView.layoutIfNeeded()
tableView.beginUpdates()
tableView.endUpdates() 

更改可能是由于iPhone X的安全区域约束变化所致。因此,我建议为框架添加参考,而不是重新加载整个数据。即使在iPhone X中,也可以很好地适合我。在各个函数中添加以下几行。

func hidenavbar((和hidetabbar((

tableView.frame = CGRect(x: 0, y: 0.01, width: view.bounds.width, height: view.bounds.height)

func dishavbar((和hidetabbar((

tableView.frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)

最新更新