Is there a global way to integrate iPhone and iPad into a universal application?

I wrote an application for the iPhone. Then I changed the interface to bit, added high-resolution images and made its version of the iPad. In an ideal world, I would like anyone who buys an iPad version to get an iPhone version for free (although not vice versa). Since Apple doesn't seem to have a way to do this (right?), My next favorite solution is to turn the iPad version into the iPhone version somehow.

I know that I could just convert the iPad version to “universal”, but since the face of the application is so different, it seems like a real pain. I have many controllers, and they almost completely differ between the two versions. Some of the methods are the same, but only about 30%. Is there a simple solution according to this:

  • Check if the device is iPhone or iPad

    • If iPhone, then use one group of files

    • If iPad, use a different file group

Thanks in advance!

+4
source share
2 answers

Try creating a new project in Xcode and select its universal application. By default, as Xcode does, there is a difference between the versions of the iPad and iPhone. You can make two versions of the application the same or different as you want.

In addition, you can check which device you are running at runtime using UI_USER_INTERFACE_IDIOM() . There are currently two values ​​for this: UIUserInterfaceIdiomPad and UIUserInterfaceIdiomPhone .

+2
source

The “simple solution” that you describe is basically how iOS downloads universal apps.

There is no other real way. You will need to combine two projects into one in order to do what you want.

The first problem will be that some (many?) Class names will be shared between both projects. You can save a little pain by using the "Refactor ..." functionality in Xcode to change the class names in one project (for example, your iPhone application, since it is older) before combining them together. The second problem will be your Info.plist; you need to make sure that the correct "main name of the main nib file", the correct supported interface orientations, icon files, etc. set to the correct value for iPad and iPhone respectively.

0
source

Source: https://habr.com/ru/post/1343404/


All Articles