1
votes

I'm working on iOS devices with retina displays. Basically, I have a UIImageView and set its image by loading a jpeg image in the documents folder.

Let's say, the UIImageView has a size 100x100 points. And the jpeg image has dimensions of 200x200 pixels. As far as I understand, the jpeg image should be viewed in the UIImageView without any scaling. I read the jpeg image as

NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];            
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/im_%d_%d.jpeg",docDir, dbPhotoId, i];
UIImage* tmpImage = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@", jpegFilePath]];

the UIImage* tmpImage has a scale factor of 1 and width and height of 200 and 200 (observed from tmpImage.scale, tmpImage.size.width and tmpImage.size.height).

In this case, if I set the image property of the UIImageView (with dimensions 100x100 points) as the tmpImage, can I safely assume that there won't be any scaling or retina display problems ?

1
You can never safely assume anything. Always test!Cyprian

1 Answers

0
votes

This depends on the value of contentMode property of the image view. If the value is UIViewContentModeScaleToFill the image will look good on retina displays but this isn't the right way to do it.

It's better to have two version of your images, one for normal display and the other for retina as explained here.