ios - UIView that loaded from nib files , can i set the owner to the view it self? -


the common method init

uiview *rootview = [[[nsbundle mainbundle] loadnibnamed:@"myrootview" owner:self options:nil] objectatindex:0];

and in case , self refer view controller , have set owner view ,because there many outlet between .m , .xib , how situations?

you should use init method in view.m class like:

- (id)initwithnibnamed:(nsstring *)nibname{      nsarray *nibcontents = [[nsbundle mainbundle] loadnibnamed:nibname owner:nil options:nil];      self = [nibcontents lastobject];      if(self){          //do code here       }      return self;  } 

and call method viewcontroller. connect view view xib.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -