我注意到我的 tableView 的最后一行在舊的 iOS 版本(<15.0)上被切斷了。
我決定根據 iOS 版本更改 tableView 頁腳,所以如果版本 >= 15.0,我想保留默認頁腳,但不知道如何。
這是代碼:
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if #available(iOS 15.0, *) {
//Problem is here. I must return something.
} else {
return 75 //This is ok
}
}
我試圖回傳
- UIView().frame.size.height
- UITableView.automaticDimension
但它甚至會產生更多問題(回傳 0)。
有沒有其他方法可以在新的 iOS 版本上回傳默認頁腳?
uj5u.com熱心網友回復:
上面的代碼必須給你默認的高度
return myTableView.sectionFooterHeight
但是,如果您僅使用頁腳視圖為視圖的底部留出一些空間,則不需要在 tableview 中添加頁腳,您可以為 contentInset 的底部留出一些空間,這將修復最后一個單元格的剪切。
在 viewdidload 上
if #available(iOS 15.0, *) {
// do nothing
} else {
self.myTableView.contentInset.bottom = 75
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/409545.html
標籤:
