[英]How to set cell height in UITableView?
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let height = self.navigationController?.navigationBar.frame.size.height
return view.frame.size.height - height!
}
我想更改單元格大小-我只使用一個單元格。
我的目的是適合屏幕。 但是,就我而言,該單元格已滾動。
我認為有必要計算安全區域。 如果我沒有更大或更小的屏幕怎么辦?
請按照以下方式計算高度,包括安全區號。
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let height = view.bounds.height - view.safeAreaInsets.top - view.safeAreaInsets.bottom
return height!
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.