Load view from an external xib file in storyboard

后端 未结 10 2269
一生所求
一生所求 2020-11-27 09:49

I want to use a view throughout multiple viewcontrollers in a storyboard. Thus, I thought about designing the view in an external xib so changes are reflected in every viewc

10条回答
  •  悲&欢浪女
    2020-11-27 10:19

    Best solution currently is to just use a custom view controller with its view defined in a xib, and simply delete the "view" property that Xcode creates inside the storyboard when adding the view controller to it (don't forget to set the name of the custom class though).

    This will make the runtime automatically look for the xib and load it. You can use this trick for any kind of container views, or content view.

提交回复
热议问题