How can I load nib from UIViews in iOS 4?

Use the method from the related question (NSBundle loadNibNamed) and make sure the owner in that call is an object that has an IBOutlet for the view in question.

Up vote 0 down vote favorite share g+ share fb share tw.

I don't have a UIViewController, since I'm adding this custom view to a parent view. I want to initialize this custom view from a nib file. Which initializer should I use?

InitWithFrame or initWithCoder? So far, I've only assigned the custom class in the interface builder. (See pic: http://cl.

Ly/7pmj). Is this necessary? If so, it is still not working, why is it not enough?

NB I've found this related question in StackOverflow. However, it doesn't explain how to initialize the view itself with the nib. I need to customize drawRect method, for this view, so I can't just add a subview from a nib file.

I need the view itself being initialized from the nib file. Thanks ios ipad ios4 link|improve this question asked Jun 22 '11 at 17:12Patrick4,6102082 99% accept rate.

Use the method from the related question (NSBundle loadNibNamed) and make sure the owner in that call is an object that has an IBOutlet for the view in question. Hook that iboutlet up to the view in interface builder (you will need to set the class of the owner in IB to the class of the owner in your load nib call). The nib will load the view into that iboutlet variable.

In . H file: IBOutlet UIView *myView; in . M file: NSBundle mainBundle loadNibNamed:@"viewToLoad" owner:self options:nil; someOtherView addSubView:myView; The rest is in IB.

Yes, it's a must to change the custom view class in your nib file. Make sure two things: 1. Go to yourCustomView.

Nib file, select the view in object, then make sure the custom class is correct under the identity inspector. 2. In the youCustomView.

M file, make sure you have this part: - (id)initWithCoder:(NSCoder*)coder { if ((self = super initWithCoder:coder)) { //add custom change after init from nib. } return self; }.

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