What exactly does a nib file look like if you were to look inside?

前端 未结 1 1667
故里飘歌
故里飘歌 2021-01-26 17:37

I\'m just learning about nibs and swift and am curious about something. I know that if you have a main.storyboard file, that a nib is loaded first fir the root view controller,

相关标签:
1条回答
  • 2021-01-26 17:54

    What exactly does a nib file look like if you were to look inside?

    Go right ahead and look inside and see! It's just an XML file; perfectly readable by a human.

    I know that if you have a main.storyboard file, that a nib is loaded first fir the root view controller, then for any views that may exist hierarchically under that view controller

    Correct! To be more precise, think of every "scene" in the storyboard as comprising two nibs, one containing the view controller, the other containing its view, the view's subviews, and everything else constituting that scene.

    When they say a nib is 'loaded' does that mean that, a single function CALLS instances of the ui objects that you would like to load, based on the storyboard that you have built in the interface builder?

    Think a nib as just a bunch of potential object instances. Loading the nib turns those potential objects into actual instances. Loading a nib is thus just another way of instantiating and configuring objects. A nib being "loaded" simply means that the nib is read and the objects it describes are instantiated and retrieved. That is why you can load the same nib multiple times to get multiple instances of those objects.

    0 讨论(0)
提交回复
热议问题