Question

I have developed an app for the iPhone. I have started trying to make my app universal and the way I am doing this is I have two nib files for each .m and .h One for the iPad and one for the iPhone. My idea was this would keep the code common but the layout unique. This may not be the best way to do it but on paper I think it looks quite neat so its the route I've chosen,unless what I want to do is impossible. I'm just wondering how do I actually navigate to a particular nib file be it the iPad or iPhone one? Could someone supply some sample code?

Was it helpful?

Solution

Simply add ~iphone and ~ipad suffix to your xib files and iOS automatically load correct xib depending on device (iPad or iPhone) where application is run. For example: if you have view controller with name ViewController then xibs should be named:

  • ViewController~iphone.xib
  • ViewController~ipad.xib

To create new object use: ViewController *viewController = [[ViewController alloc] init];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top