There are lots of helpful information available on internet, so just share some notes I found useful during application development, to contribute back to the community. Jonathan in Toronto
Thursday, May 3, 2012
xib, view and viewcontroller
It is a little confusing how xib, view and viewcontroller works together in ios application.
When app starts, it creates an instance of viewcontroller class, viewcontroller class asks to load xib file by calling initnibwithname mtheod, this will load the xib file into memory. At this moment, the owner of the xib file is viewController instance. It is more clear if this is done with [NSBundle loadNibNamed] method. The next step is mapping the outlet from xib resource objects to the viewcontroller instance's IBOutlet, usually this involves passes a view object to viewcontroller's view property. Once this is done, it totally depends on viewcontroller to decide how to display its view property on screen.
So basically, what xib file does is creating all resource objects and associating them to the specified IBOutlet variable, and leave the owner to use it. Note the instance asks to load the xib must be the type specified in xib's file owner type, so that the IBOutlet settings can be matched between the real owner and xib file.
Jonathan
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment