2017-03-29 42 views
3

我有一個分組 UITableView。我實施了tableView(:titleForHeaderInSection :)tableView(:titleForFooterInSection :)。當我滾動一張長桌子時,我可以看到部分頁眉和頁腳包含了預期的數據。當我到達桌子的底部,然後拖動以查看最後一部分的頁腳時,它具有正確的數據,但是當我釋放手指時,頁腳向下滾動,超過屏幕底部並且不在視圖中。最後一節的最後一個單元格出現在屏幕的底部,而不是最後一節的頁腳。UITableView - 上一節的頁腳從屏幕底部滾動。如何預防?

如何解決? There's the last section and its footer. My finger is still on the screen

When I release my finger, the final footer slides off the bottom of the screen.

回答

1

您可以通過考慮以下method之一來修復滾動內容問題。

方法1:StoryBoard設置您的tableView framebottom constraint妥善解決您的問題自然的方式。

更新時間:

enter image description here

方法2:您可以驗證tableView frameviewDidLayoutSubviewsviewWillLayoutSubviews

override func viewDidLayoutSubviews() { 
tableView.frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: tableView.frame.height - (tabBarController?.tabBar.frame.size.height)!) 
} 

方法3:通過調整設置你的tableView框架滾動視圖insets

override func viewDidLayoutSubviews() { 
tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: (tabBarController?.tabBar.frame.size.height)!, right: 0) 
} 
+1

我用了一個TableViewController,並找不到調整tableView的方法,如vids(很好的觸摸!)所示。我探討了一個能夠使用方法3,似乎工作。其中一天,我會理解它。謝謝。 – MACE

+0

很高興我幫助... – Joe

1

我認爲這是阻止使用TabBar。
如果使用storyborad,請重置tableView的約束條件。
如果不是,則需要正確設置tableView的框架。

+2

確保表視圖的底部約束鏈接到「底部佈局指南」,而不是「容器邊距」。 – paulvs

+0

啊!我在任何地方都沒有明確的約束。但是「標籤欄」的背後很有意義。我會追求這一點。謝謝。 – MACE

相關問題