[英]How to scroll to bottom of UITableView to see all cell contents without adjusting cell height?
[英]Auto Cell Height on UITableView without overlapping bottom part of iPhone X
所以我的目標是為我的表格視圖實現自動高度。 我的意思是每當我向表格視圖添加新項目時,表格仍然是“全屏”,而單元格正在降低其高度。
例如,這就是我所做的:
我已經使用代碼實現了這一點:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let itemCount:CGFloat = CGFloat(items.count)
let statusHeight = UIApplication.shared.statusBarFrame.height
let navHeight = self.navigationController!.navigationBar.frame.height-statusHeight
let viewHeight = view.bounds.height
let cellHeight = (viewHeight-navHeight)/itemCount
return cellHeight
}
但問題是,在 iPhone X 中,它正在做類似的事情:
底部項目的底部被切割/重疊。 我該如何解決?
謝謝你。
編輯 :
感謝您的回答Trupesh Vaghasiya和潘卡我做你的解決方案,無法找到它,但是這是我做了什么{截圖}
但結果是這樣的 { iPhone X Screenshot }。 你不認為這違反了 iPhone X UI 指南嗎?
只需更改與 superView 相關的界面約束,而不是安全區域。 檢查您的 tableview 頂部和底部約束並使其與 superView 相關。 但正如蘋果所說,如果你讓它與安全區域相關是好的,因為 iPhone X 和更高版本的屏幕上有主頁按鈕。 您可以查看以下屏幕截圖。 選擇底部約束
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.