iOS 15 的 Static Cells 的 section header / footer 顯示問題

在 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 的表格不用擔心此問題。

--

--

彼得潘的 iOS App Neverland
彼得潘的 Swift iOS App 開發問題解答集

彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,彼得潘的 Swift 程式設計入門,App程式設計入門作者,http://apppeterpan.strikingly.com