Pregunta

I would like to make it so that my iPhone app also works on iPad.

If I run it using the iPad simulator it does work, but the app doesn't show up on the iPad app store, and looks really weird.

Is it possible to create another .xib file for the iPad? I know how to add a new iPad .xib file, yet I don't know how to actually change the RootViewController.xib to RootViewController_iPad.xib if the device being used is an iPad.

I already have code for finding out if the device is an iPad, and I don't want to use auto-layout, because I would like to add different things to the view if they are using an iPad (such as using different images).

I would like to make it so that my iOS applications look good on both iPhone and iPad, and have a separate .xib files for each. Is it possible to change the default .xib file from RootViewController to RootViewController_iPad?

¿Fue útil?

Solución

In order to make an application work in both iPhone & iPad then need to follow below steps.

  1. Before create an project please select universal in device section.
  2. In application: didFinishLaunchingWithOptions: put a condition to check the device.
  3. If the device is iPad then load the iPad screen and if the device is iPhone then load the iPhone screen.
  4. Make sure follow the MVC pattern, So that it is easy to populate the data in both the screens.

Otros consejos

@class has no effect on outlets or actions it only tells the compiler that there is a class with the name that follows, no information about properties, or methods is included.

If you want to have a xib for the iPad don't create a new class for it, just create a new xib and set the file's owner to be the same as the what owns iPhone xib. You then need to add a check in application: didFinishLaunchingWithOptions: to load the correct xib.

The best option though is to tell Xcode you want a universal app when you create the project.

The key point here is that it must be a UNIVERSAL application. Its a setting when you set the app up for the 1st time. You will end up with 2 UI's (story boards or xib files).

You will have to create 2 seperate UI's for ipad and iphone. You may be able to use the main class itself for most of the code but then you have to basically put code that says

if its iphone.....

if its ipad ......

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top