Creating a reusable UIView with xib (and loading from storyboard)

前端 未结 6 1055
孤独总比滥情好
孤独总比滥情好 2020-11-28 18:49

OK, there are dozens of posts on StackOverflow about this, but none are particularly clear on the solution. I\'d like to create a custom UIView with an accompan

6条回答
  •  悲哀的现实
    2020-11-28 19:30

    Note that this QA (like many) is really just of historic interest.

    Nowadays For years and years now in iOS everything's just a container view. Full tutorial here

    (Indeed Apple finally added Storyboard References, some time ago now, making it far easier.)

    Here's a typical storyboard with container views everywhere. Everything's a container view. It's just how you make apps.

    enter image description here

    (As a curiosity, KenC's answer shows exactly how, it used to be done to load an xib to a kind of wrapper view, since you can't really "assign to self".)

提交回复
热议问题