Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device-Specific Resources in iPhone

According to the iOS Reference Library:

In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device.

Does this mean that if you're creating an Universal app for 3.X devices, and the 3.2 iPad in particular, you can't use device-specific resources with the ~ipad and ~iphone sufixes?

If so, is this the correct way to deal with 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 know of?

like image 421
hpique Avatar asked Oct 17 '10 10:10

hpique


People also ask

Where is device management on my iPhone?

You can see the profiles you have installed in Settings > General > VPN & Device Management. If you delete a profile, all of the settings, apps, and data associated with the profile are also deleted.

What is on demand resources?

On-demand resources are app contents that are hosted on the App Store and are separate from the related app bundle that you download. They enable smaller app bundles, faster downloads, and richer app content. The app requests sets of on-demand resources, and the operating system manages downloading and storage.

What can Apple MDM see?

Once users are enrolled in MDM, users can easily view in Settings which apps, books, and accounts are being managed and which restrictions have been implemented. All enterprise settings, accounts, and content installed by MDM are flagged as managed. This includes Wi-Fi and VPN configurations and password requirements.


1 Answers

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

As a workaround I've created a category in UIImage, so I can use it like anImage = [UIImage mbImageNamed:@"MyImage.png"]. Category method simply puts "~iPad" before the suffix on iPad - code similar to yours.

Another ugly thing is that UIWindowControllers do not load xib files depending on device. I've created a base class for all my window-controllers and load the iPad specific XIB:

@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
like image 189
Michal Avatar answered Sep 30 '22 15:09

Michal