Trouble with loading a separate XIB for iPad or iPhone

后端 未结 3 1031
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 03:37

Im having trouble figuring out how to load a separate XIB for iPad or for iPhone in a Universal app.

Its easy enough to convert the Xcode project to Universal and ha

3条回答
  •  余生分开走
    2020-12-10 03:55

    You can use UI_USER_INTERFACE_IDIOM() to check whether the application is running on an iPad or an iPhone/iPod touch:

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        // Running on iPad
    } else {
        // Running on iPhone or iPod touch
    }
    

    For more information on loading NIB files, read Apple's Resource Programming Guide on Nib Files. You may want to specifically check out the Loading Nib Files Programmatically section which shows how to programatiically load a NIB from within your code using NSBundle. You can then use this in conjunction with the above code to correctly load the proper NIB depending on which device you're runining on.

提交回复
热议问题