Use Storyboard References While Retaining Icons & Text for Tab Bar Controller

前端 未结 6 1097
刺人心
刺人心 2021-01-17 08:45

I started refactoring one of my projects to make the code easier to manage and the Tab Bar Controller lost its icons for which tab represents what. Without this I\'m a bit l

6条回答
  •  执念已碎
    2021-01-17 09:22

    Update - This approach no longer appears to work in Xcode 9.

    Here's how to get the tab to show properly:

    1. Put the first UIViewController that will be embedded in the tab in the same storyboard as the UITabViewController.
    2. Ctrl + Drag from the tab bar controller to the content view controller to make the connection as per usual. This will automatically add the UITabBarItem to the bottom of the content view controller.
    3. Select the content view controller.
    4. Click the Editor menu and choose Refactor to Storyboard...

    5. The UITabBarController tab will now point to the new storyboard reference...

    6. ... and the content view controller preserves the UITabBarItem from the tab bar relationship. It will appear normally in the app now.

提交回复
热议问题