lundi 1 décembre 2014

UIImage initWithContentsOfFile load wrong image scale in iPhone 6

I found a very wired issue and I can reproduce it every time. Say you have three images: test.png, test@2×.png, test@3×.png, and you load your image by the following code:



NSString* path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"];
UIImage* image = [[UIImage alloc] initWithContentsOfFile:path];


Then in iPhone6 the scale of the image will always be 3 instead of 2.


but it you load the image by



UIImage* image = [UIImage imageNamed:@"test"];


Then the scale of the image is 2 just as expected.


Does anyone know this issue? I tested the issue in Xcode 6.0.1 with OS X 10.9.5




Aucun commentaire:

Enregistrer un commentaire