簡體   English   中英

使用 XIB UIViewController 和 Storyboard

[英]Using XIB UIViewController with Storyboard

我有一個 storyboard,我在其中保留了我的主標簽欄 controller,我正在進行一些更新,並想添加一個視圖標簽 controller 我已經用 XIB 文件構建了。 如何在我的標簽欄上使用該 View controller? 我應該將視圖復制並粘貼到我的 storyboard 文件中嗎?

當然,您可以在 storyboard 中創建一個新場景並將視圖復制到 storyboard 中。 話雖如此,如果您將該 XIB 用於其他事情,那么您將需要維護兩個視圖副本,這並不理想。

有幾種方法可以解決這個問題。 可能最簡單的方法是將使用 XIB 加載視圖 controller 的位置轉換為從 storyboard 加載它,然后完全刪除 XIB。

要考慮的另一種方法是不將其添加到 storyboard 中,而是在viewDidLoad實現中從 XIB 加載視圖 controller 並將其插入標簽欄 Z594C103F2C6E04C3D18AB059F031E。 The most appropriate place for this would be either in a subclass of UITabBarController that you then set as the type of your storyboard tab bar scene or in a subclass of UIViewController that you setup as a container view controller in your storyboard with the tab bar controller embedded作為子視圖 controller。 任何一個地方的viewDidLoad實現都可能是合理的。

暫無
暫無

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

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