Gui*_*tro 13 storyboard uitableview ios
我的桌面视图底部有一个额外的空间,如图所示:
tableView中的所有行都具有71pt的固定高度.

@urgentx 的回答满足了我的大部分要求,但没有完全实现。我处于类似的情况(聊天应用程序的 UITableView 颠倒),但是他们的建议完全禁用安全区域行为,这在 iPhone X 等设备上是不可取的,因为这意味着桌面视图将被主页指示器和任何其他设备剪切。顶部导航栏。
我执行了以下操作,以便使表格视图在倒置时仍然正确地避开安全区域:
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
self.tableView.contentInsetAdjustmentBehavior = .never
}
Run Code Online (Sandbox Code Playgroud)
进而:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
//fetch the safe area in layoutSubviews since this it's possible that they can change when the device is rotated
let safeArea = self.tableView.safeAreaInsets
//insets are **flipped** because the tableview is flipped over its Y-axis!
self.tableView.contentInset = .init(top: safeArea.bottom, left: 0, bottom: safeArea.top, right: 0)
}
Run Code Online (Sandbox Code Playgroud)
这本质上复制了contentInsetAdjustmentBehavior = .automatic行为,但插图在 Y 轴上翻转。
| 归档时间: |
|
| 查看次数: |
26334 次 |
| 最近记录: |