iOS Development: How can I prevent an iPad from running a universal app in iPad mode?

前端 未结 9 1323
死守一世寂寞
死守一世寂寞 2020-12-31 04:50

I\'m diving into iOS development and I created a universal app that turned into an iPhone-only app. When it runs on the iPad, it just loads a white screen since there\'s no

相关标签:
9条回答
  • 2020-12-31 05:38

    I think there is an entry in the info.plist file for each of the devices that says which main window to load. Maybe a quick and dirty solution would be to set both MainWindow-iPhone and MainWindow-iPad to the same -iPhone- main window.

    0 讨论(0)
  • 2020-12-31 05:42

    Since Xcode 5, you can chose your development target devices from the Project:

    From the devices section within Development Info, now you can choose:

    1-iPhone 2- iPad 3- Universal

    enter image description here

    0 讨论(0)
  • 2020-12-31 05:43

    When an iPad runs a universal app, how does it know to run it in "iPhone mode" or execute the iPad specific code?

    The iPad looks for the Targeted Device Family, if the iPad is not present, then it knows it must run the app in iPhone mode.

    In a universal app, how does it know which code is iPhone and which code is iPad?

    When you write the code for the app, you must specify what device you are targeting if there are specific things you need to do per device. (see the code example below)

    How can I prevent the iPad from trying to run the iPad code and, instead, run the iPhone code?

    Do not support iPad in your Targeted Device Family. Second, in your code, do not specify that specific code needs a specific device, for example:

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        /* run something specific for the iPad */
    } 
    else
    {
        /* run something specific for the iPhone */
    }
    
    0 讨论(0)
提交回复
热议问题