display image in iphone 4 retina display

2.5k views Asked by At

I am showing a high resolution image in iphone 4 and i set the image view frame size as below : imageFrameNormal.size.width = 470; imageFrameNormal.size.height = 625;

but it showing full screen instead of this size. so plz can any one suggest how i show image in right size. i am trying to check it in simulator.

Thx

2

There are 2 answers

0
Max On BEST ANSWER

You have to use the same sizes on retina and normal displays. For example, you have image view with size 100x100. On retina device you should use the same size 100x100 (no changes in your code). However you'd better use high-res image (2x size). For this you need to name it properly: image.png - normal size image [email protected] - 2x size image.

When you call

UIImage* img = [UIImage imageNamed: @"image.png"];

image.png would be used on normal display and [email protected] on retina (iOS does it automatically).

0
rcw3 On

The retina display's coordinate system is not in pixels, but in "points". The iPhone display, whether retina or legacy will always be 320x480 points. When interacting with any parameters such as the frame, size, origin, etc., you will need to remember to use points instead of pixels. The OS will handle the "conversion" between points and pixels for you.

For a much more detailed explanation, see Points vs. Pixels in the Drawing and Printing Guide for iOS.