iphone - What is the best way to load a custom UIView? -


in iphone app, made custom uiview use in several different view controllers display information.

i'm familiar making customer table cells use in table i've never made custom view again.

my question best way load view? i've tried placing view in view controllers want appear in using ib, doesn't seem enough. seems me make sense if set class identity view should load view when view controller created. or maybe doesn't because doesn't know nib (it's in own nib, of course).

since it's not view controller, can't use initwithnibname. i've tried using nsbundle loadnibnamed table cells seems awfully large amount of work. code looks this:

nsarray *toplevelobjects = [[nsbundle mainbundle] loadnibnamed:@"mycustomview" owner:nil options:nil]; (id currentobject in toplevelobjects) {     if ([currentobject iskindofclass:[mycustomview class]]) {         self.customview = currentobject;         break;     } } [self.view addsubview:self.customview]; 

there must easier way doesn't involve loop. also, creating view way makes me lose info ib on placed view. it's created @ 0,0 not want it. yes, know can set new frame, again, there must easier way. there way can through ib? or @ least less work programmatically?

i make way. ran problem want subclass uiview , using nib @ same time. don't think there's better way so, because nib file can contains many objects , have specify 1 use. however, way can put iboutlet in mycustomview , bind in ib view can manage e.g. overriding layoutsubviews.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -