I develop application for iPad 3 – with Retina display. I calculated, based on specification, that image should be 1536 x 2008 to fill (with a statusbar) entire screen. I resized image to such dimensions, and I programmatically load it and sets it to display on UIImageView (loaded from storyboard). What is more, to get best performance I set up UIImageView mode to Center (to avoid scaling). When I run app I see only center of my image – as if my image was 4 times the screen – which is not true.
Hers my code of viewWillAppear method
UIImage *image = [UIImage imageWithContentsOfFile: self.pageData.pageFilename];
NSLog(@"Image size: %f %f", [image size].width, [image size].height);
NSLog(@"Image view size: %f %f", self.imageView.frame.size.width, self.imageView.frame.size.height);
[ self.imageView setImage: image];
And I get in output:
Image size: 1536.000000 1990.000000
Image view size: 768.000000 1004.000000
How to correct this? My image is JPG with size you can see, and 72 DPI – but I’m sure that DPI doesn’t matter
You are mixing up pixel and points.
In iOS dimensions are measured in points, not in pixles. If the device uses retina display, then 1 point = 2 pixel. Using the old display you have 1 point = 1 pixel.
Normal display
1 point = 1 pixel
1024 * 768 points
1024 * 768 pixel
Retina display
1 point = 2 pixel
1024 * 768 points
2048 * 1536 pixel
So in both cases the size of the display has the same size:
1024 * 768 points