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

前端 未结 9 1322
死守一世寂寞
死守一世寂寞 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:19
    1. The iPad looks into the application's Info.plist, for the UIDeviceFamily key, which is an array. The value '1' indicates iPhone/iPod Touch, '2' indicates 'iPad'. If there's a '1' but no '2' then you get the simulated iPhone environment. This value is written to the Info.plist automatically as a result of your 'Targeted Device Family'. If you think you've set it to iPhone but are still getting an iPad build, check you didn't just set it for one build configuration. Check the Info.plist within your produced app bundle if you want to be really confident.
    2. There's only one binary, which you write to launch correctly on either device.
    3. Just don't target the iPad.
    0 讨论(0)
    1. If you build an universal app, it will use your iPad code. It is not possible to run a universal app in "iPhone Mode". Apple will check that you have followed the iPad design specifications.

    2. In a universal app, there are two app-delegates: AppDelegate_iPhone.h and AppDelegate_iPad.h

    3. You can add your iPhone code in the AppDelegate_iPad, but Apple will not be pleased.

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

    You should NOT add this to your Info.plist file. Instead, add it to your build settings per Apple's suggestion. Specifically, use the TARGETED_DEVICE_FAMILY build setting.

    If you are using storyboards, you also want to remove the UIMainStoryboardFile~ipad key from your Info.plist as it will be used regardless of your TARGETED_DEVICE_FAMILY setting.

    Good luck!

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

    I think that something is wrong with your configuration, because if you target the code for iPhone only Device, the app will bu runnable on an iPad with the screen that was designed for iPhone (so, reduced, with the possibility to x2).

    • the proposals from the AppStore (iPhone/iPad/both) depend on the user's preferences
    • you can experiment it with the Simulator (and choose iPad as the Device)
    • the code is the same for iPad/iPhone ! ... unless you use [[UIDevice currentDevice] userInterfaceIdiom] mentioned supra...
    0 讨论(0)
  • 2020-12-31 05:34

    I'm assuming what you actually want is to remove the "universal" capability, and just make it an iPhone app.

    In Xcode, go to Project => Edit Project Settings => Build.

    Search for universal, or 'Targeted Device Family'.

    Pick iPhone.

    Goodbye iPad.

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

    Another way to do it (with code) is:

    In your App's AppDelegate (if your App was created as an Universal App) you can find the following code:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {   
        // Override point for customization after application launch.
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
            //iPad...
    
        } else {
            //iPhone and iPod Touch...
    
        }
    
        return YES;
    }
    

    There you can customize what view to show.

    0 讨论(0)
提交回复
热议问题