Benr783
Benr783

Reputation: 2890

Get a specific view controller from a xib?

I don't like auto layout, so I just use the typical Xcode 5 storyboards. I have a View Controller in my xib for each screen size. How can I, programmatically, get the view controller that is the right size and then present that?

Upvotes: 1

Views: 151

Answers (2)

Robasan
Robasan

Reputation: 155

I used to hate Interface Builder and Autoresizing mask. I had placed subviews programatically. But I changed my mind since I understood Auto Layout. Almost all of layout things will be very easy if you understand Auto Layout. I know some situations need to write codes. You can use xib to make custom view for complicated layout. And also you can make custom views fully programmatically.

Xib file does not support Layout Guide. My solution is to make storyboard for each ViewController. Layout Guide things messed you up if you try to layout programmatically.

Upvotes: 1

Nick Wilkerson
Nick Wilkerson

Reputation: 385

You should not use separate view controllers for different screen sizes. You should use the same view controller, and load a different xib depending on the screen size. You will probably have the same elements in the xibs for the different screen sizes so a single view controller should be able to handle any size.

Upvotes: 2

Related Questions