27

I have created a custom class that subclasses UIView. I want to do my layout in IB, so have set outlets. The problem is how do I initialise my view so that I get it from the NIB? Any help would be greatly appreciated.

1 Answer 1

56

Something like this:

UIView *info = [[[NSBundle mainBundle] loadNibNamed:@"InfoWeather" owner:self options:nil] objectAtIndex:0]; 
Sign up to request clarification or add additional context in comments.

3 Comments

Where do I put this? I've put it in my View's class init method and am then adding this view as a subview but still no luck.
I put it in my UIViewController init and call [self.view addSubview] too. All looks good.
Very nice solution. But it only works when the UIView is not to be updated.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.