Add a UIView to a UIViewController with Xib -
here trying do:
- i have
aviewcontroller
, it's xib, adduiview
half screen connect view b-uiview , b-uiview has own xib design.
in other words have view controller it's view becomes "mainview" add other views come own xibs.
hierarchy:
1 viewcontroller
uiview (xib) 2.b-uiview (has own xib) 3.c-uiview (has own xib)
so possible if how?
many in advance!
yes, can , it's not difficult @ all!
in fact, it's pretty common way design in interface builder. can load custom xib file programmatically using loadnibnamed
. example:
[[nsbundle mainbundle] loadnibnamed:@"tvcell" owner:self options:nil];
apple's docs talk in "table view programming guide ios".
although example creating custom table cell, same rules apply view. have close @ section entitled loading custom table-view cells nib files.
one thing don't in example load top level view. loadnibnamed
returns array, top level view you're after, should do:
mycustomview *mycustomview = [mynibsarray objectatindex:0];
so, code like:
nsarray *mynibsarray = [[nsbundle mainbundle] loadnibnamed:@"mycustomview" owner:self options:nil]; mycustomview *mycustomview = [mynibsarray objectatindex:0];
Comments
Post a Comment