IPhone Specific Resources

According to the iOS help library :

In iOS 4.0 and later, to mark individual resource files as you can only use for a certain type of device.

Does this mean that if you create a universal application for devices 3, X and, in particular, 3.2 iPad, you can not use the resources specific to the device using ~ipad and ~iphone sufixes?

If so, is this the case for device specific resources?

 UIImage* anImage; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { anImage = [UIImage imageNamed:@"MyImage-iPad.png"]; } else { anImage = [UIImage imageNamed:@"MyImage-iPhone.png"]; } 

Any additional considerations I should be aware of?

+6
ios iphone resources ipad universal-binary
source share
1 answer

Yes, you're right, this feature does not work with current iPads - iOS 3.2.

As a workaround, I created a category in UIImage, so I can use it as anImage = [UIImage mbImageNamed:@"MyImage.png"] . The category method simply places the β€œ~ iPad” before the suffix on the iPad β€” a code similar to yours.

Another ugly thing: UIWindowControllers do not download xib files depending on the device. I created a base class for all of my window controllers and downloaded the iPad XIB-specific:

 @implementation MBPadAwareWindowController - (id)init { NSString *className = NSStringFromClass([self class]); NSString *nibName = UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad ? className : [className stringByAppendingFormat:@"-iPad"]; return [self initWithNibName:nibName bundle:nil]; } @end 
+2
source share

All Articles