Right behavior? - iPhone application running on iPad downloads xib with ~ ipad extension

I came across the fact that, in my opinion, some strange behavior in iOS - the search for StackOverflow did not show anything similar to my problem.

Essentially, if you have two .xib files with device modifiers (~ iphone and ~ ipad) and you run the iPhone application (NOT universal) on the iPad (i.e. in the iPhone simulator window), it will try to download ~ ipad xib, and not ~ iphone xib.

This is mistake? I would expect to download ~ iphone xib. Although the actual device is an iPad, it mimics the iPhone, right? So he should download the iPhone interface file?

Steps to play:

  • Create a new iPhone application (not universal) in Xcode - use the "Single View" template.
  • Rename ViewController.xib to ViewController ~ iphone.xib
  • Duplicate and rename xib, so now you have ViewController ~ iphone.xib and ViewController ~ ipad.xib
  • Run this iPhone application in the iPad simulator (or on the iPad itself) - it loads ~ ipad XIB, not ~ xix xib.

Can someone tell me how I can get around this problem? This is difficult because my actual Xcode project has several goals (1. iPhone-only app 2. iPad-only app), so I need to support all the scenarios, therefore, use device modifiers.

+4
source share
1 answer

I usually do this when working with tips:

- (id)init { if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomiPhone ) { nibNameString = @"mynib-iPhone"; } else { nibNameString = @"mynib-iPad"; } self = [super initWithnNibName:nibNameString bundle... 
0
source

Source: https://habr.com/ru/post/1411764/


All Articles