iPhone app running on iPad loads xib with ~ipad extension

I've stumbled across what I think is some odd behaviour in iOS - a search of StackOverflow hasn't turned up anything identical to my problem.

Essentially, if you have two .xib files with device modifiers (~iphone and ~ipad), and you run an iPhone app (NOT universal) on the iPad (ie within the iPhone simulator window) it will attempt to load the ~ipad xib file rather than the ~iphone xib.

Is this a bug? I would expect the ~iphone xib to be loaded. Even though the actual device is an iPad, it's emulating an iPhone, right? So surely it should load the iPhone interface file?

Steps to reproduce:

  • Create a new iPhone (not universal) app in XCode - use the 'Single View' template.
  • Rename ViewController.xib to ViewController~iphone.xib
  • Duplicate and rename the xib, so that you now have ViewController~iphone.xib and ViewController~ipad.xib
  • Run this iPhone app within the iPad simulator (or on an actual iPad device) - the ~ipad XIB is loaded rather than the ~iPhone xib.
  • Can anyone suggest how I might work around this issue? It's complicated because my actual XCode project has multiple targets (1. iPhone-only app 2. iPad-only app) so I need to support all scenarios, hence the use of device modifiers.


    我在使用笔尖时通常会这样做:

    - (id)init
    {
        if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomiPhone )
        {
            nibNameString = @"mynib-iPhone";
        }
        else
        {
            nibNameString = @"mynib-iPad";
        }
        self = [super initWithnNibName:nibNameString bundle...
    
    链接地址: http://www.djcxy.com/p/95714.html

    上一篇: 通用应用在iOS 6模拟器中使用错误的Xib for iPad

    下一篇: 在iPad上运行的iPhone应用程序会加载带〜ipad扩展名的xib