running iPhone app on iPad crashes

Discussion in 'iOS Programming' started by gbenna, Aug 13, 2012.

  1. gbenna macrumors member

    Jul 27, 2011
    I have an iPhone app that I would like to run on the iPad. It works fine on the iPhone but when I try to run it on the iPad simulator it crashes at the beginning. The crash log says,

    " Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UISplitViewController is only supported when running under UIUserInterfaceIdiomPad'"

    I have tried to delete the code

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
            UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
            UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
            splitViewController.delegate = (id)navigationController.topViewController;
        return YES;
    from the appDelegate but with no change.

    I'm sure this is easy, but I don't know how.

    Does anyone know what I need to do to make this work?

  2. Duncan C macrumors 6502a

    Duncan C

    Jan 21, 2008
    Northern Virginia
    It sounds like you have your app set up to run as an iPhone-only app. In that case, it runs in compatibility mode when run on an iPad. Thus, you need to hunt down and comment out all code that uses iPad-only APIs like split view controllers, popovers, and the like.

    If you commented out the code that you posted and it's still complaining that split view controllers aren't supported, you missed something.

    Alternately, you can make your app universal, in which case it will run as an iPhone app on an iPhone and as a native iPad app on iPads. That requires a fair amount of rather fussy work, however. At a minimum, You need to set up your code to load different versions of the the nibfiles for all your view controllers. Better yet, though, you need to rethink your design and figure out where you can combine functions on one screen. If you're willing to require iOS 5, you can use the new parent/child view controller facilities of view controllers, and combine the contents of multiple view controllers in a parent view controller.

Share This Page