Search code examples
iphoneipaduniversal

Converting an iPhone app to a Universal app?


I have an iPhone app with FirstViewController and SecondViewController with respective views FirstView.xib and SecondView.xib.

Now I want to make this app work with both iPhone and iPad. For iPad I need to merge Firstview.xib and SecondView.xib into a single ThirdView-iPad.xib.

What would be the best approach? Do I need to write another ViewController class for iPad or can I use existing FirstViewController and SecondViewController with single xib?

My research so far says that there is no way to use multiple ViewControllers with single xib. Please let me know the best way to do this.

Thanks


Solution

  • You would be best of to just create a new ViewController unless you're into masochism. Reusing in that way would most likely be to much trouble, and I'd go with aggregation or inheritance in the case you need to reuse logic in your ViewControllers.

    I typically create a base ViewController, say XYZViewController and then create a XYZViewController_iPhone with all iPhone-specials and a separate XYZViewController_iPad for iPads. But if they're totally different I give them unique names and their own NIBs as well as ViewControllers.