How to load a UIView from a NIB?

Up vote 5 down vote favorite 7 share g+ share fb share tw.

I have been using UIViewControllers and initWithNibName with much success, basically using them as a convenient way to design the view with Interface Builder. Unfortunately I have built a hierarchy of views before noticing this line in the UIViewController documentation: Note: You should not use view controllers to manage views that fill only a part of their window My question is this: Having a very simple NIB that only has a UIView in addition to the default First Responder and Owning Object, what is the simplest way to load the UIView into my code? I have not been able to get loadNibNamed:owner:options: to work at this point, but suspect the answer will involve it somehow.

Iphone objective-c uiview nib link|improve this question edited Apr 15 '10 at 19:53 asked Apr 15 '10 at 19:20Winder848919 85% accept rate.

Yes, just call NSBundle mainBundle loadNibNamed:@"viewNib" owner:self options:nil; You normally do this from the view controller you have set as File's Owner in the NIB. That way, you can declare an outlet for the view in the view controller which will automatically get connected when you load the NIB file. You don't even have to work with the return value of the method in this case.

– Patrick Jun 23 '11 at 8:32 Just the view's class to your custom class in IB and then connect the outlets. No difference to what you would always do. – Ole Begemann Jun 23 '11 at 8:50 but what do I have to do if this UIView is already build on the nib and I want to reuse it?

– Vova Stajilov Feb 11 at 11:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions