簡體   English   中英

帶有填充可見屏幕區域的單元格的靜態表視圖

[英]Static Table View with Cell that fill visible screen area

我想創建一個包含7個單元格的靜態表,並考慮到狀態欄和導航欄,以填充屏幕的其余部分。 我重寫下面的方法,但是沒有得到預期的結果。 我缺少什么?

    override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
    let tableHeight = (CGFloat(tableView.bounds.height) - CGFloat(64))/7

    return tableHeight }

圖片顯示我的7個單元格沒有占據整個屏幕 具有7個單元格的靜態表格視圖

嘗試這個

override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {
    let tableHigh = (CGFloat(UIScreen.mainScreen.bounds.height) - CGFloat(64))/7

    return tableHigh }

這是另一個很好的解決方案:

override func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath) -> CGFloat {

    let tableHeight = (tableView.bounds.height - tableView.contentInset.top - tableView.contentInset.bottom) / 7

    return tableHeight
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM