Using +[UIImage imageNamed:] from a +load method returns non-retina graphics

Originator:danielctull
Number:rdar://13959179 Date Originated:22-May-2013 11:18 AM
Status:Open Resolved:
Product:iOS SDK Product Version:6.1.4
Classification:Other Bug Reproducible:Always
 
Summary
I use imageNamed: in a class' +load method and the returned image has a scale of 1 on retina devices.

Steps to Reproduce:
Implement a load method similar to:

+ (void)load {
	UIImage *image = [[UIImage imageNamed:@"DBSGreyButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 13.0f, 0.0f, 13.0f)];
	NSLog(@"%@", @(image.scale));
}

Expected Results:
The retina version of the image to be loaded.

Actual Results:
The non retina image is loaded.

Notes:
Chris Parker says this is because "+load fires before UIApplication init so scale isn't set up yet" (https://twitter.com/ctp/status/334215372611940352).

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!