With Interface Builder create subview with own NIB and UIViewController?

If I understand your question correctly, you can make a new view controller or view, with it's own xib, and then go back to your original controller's xib, add a new "subview" and change the class of your subview to that new view controller.

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

I would like to create a subview of an existing view, where the subview has its own XIB-file and its own ViewController. I know that is only a view lines of code programmatically, but I really want to learn how to use Interface Builder better. Does anybody know how to do this in XCode-4 / Interface Builder?

Or, stated differently, suppose I have created one nib with my main user interface in it (let's say "main. Xib"). Now I create a second view NIB "second.

Xib", which is linked to its own viewcontroller ("secondViewController. M"). How do I tell IB to add the second view as a subview in the main.

Xib? Ios xcode4 uiviewcontroller interface-builder nib link|improve this question edited Feb 24 at 21:57 asked Feb 24 at 11:55fishinear6318 54% accept rate.

I have read your question 8 times and have absolutely no idea what do you want to achieve. – lawicko Feb 24 at 12:20 @lawicko I have added a clarification, hope that makes it more clear. – fishinear Feb 24 at 21:57.

If I understand your question correctly, you can make a new view controller or view, with it's own xib, and then go back to your original controller's xib, add a new "subview" and change the class of your subview to that new view controller. But that's just a part of what you need. I'm afraid there is no way to do this completely with IB.

I can drag a new view from the library to the existing view, and it becomes a subview. But I cannot change the class of that subview into my viewcontroller. How do I tell IB that that subview is described by a separate NIB and associated view controller?

– fishinear Feb 24 at 21:50 When you select that new view, go to the Identity tab, and not Attributes. From there, you can change the view's class from standard UIView to another custom UIView class (I don't know if you can assign it a new UIViewController derived class, I only did this with another UIView class). Then, in your viewDidLoad you load the new NIB (NSBundle mainBundle loadNibNamed:@"MyNewView" owner:self options:nil).

When you'll access that view controller, the subview should act just like the custom one – Bogdan Bucur Feb 27 at 7:28 I am sorry, but IB only allows me to change the class into another View derived class, not into a viewController. – fishinear Feb 27 at 12:50 Yes, as I said, I did this only for a custom UIView. Again, it is not possible to do exactly what you want, my answer only covers what you can do and it's somewhat related to what you're searching for, sorry.

– Bogdan Bucur Feb 27 at 13:18 OK, thanks for the help. I will just stick with adding it programmatically for now. – fishinear Feb 27 at 14:12.

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