iOS 15 的 Static Cells 的 section header / footer 顯示問題
Published in
Jun 27, 2021
在 iOS 15 當我們使用 table view controller 搭配 Static Cells 的 table view 時,將遇到特別的 header / footer 顯示問題。
以下我們用 Static Cells 製作精美的 Apple Store 列表。
我們沒有設定 header / footer 的內容,但是 App 執行後卻出現以下問題。
- 上方多了一塊 header 佔據的空白區塊。
- 滑動時看到灰色的 header / footer
解法: 調整 Section Header / Footer 的高度
點選 table view,切換到它的 Size inspector 頁面。如下圖所示, Section Header / Footer 預設的高度都是 Automatic。
只要取消 Section Header / Footer Estimate(預估) 的 Automatic,輸入 0 讓它取消自動計算高度,即可不再看到 header / footer。
Cool,終於恢復正常了,礙眼的 header / footer 消失了。
此問題只有 Static Cells 會遇到,Dynamic Prototypes 的表格不用擔心此問題。