Noob question about resolution (Retina vs Original)

Discussion in 'iOS Programming' started by Kahnyl, Mar 21, 2011.

  1. Kahnyl macrumors 68000

    Joined:
    Feb 2, 2009
    #1
    I had an idea to get something really simple up and running on my phone as a way to learn. I just wanted to get a large image to scroll up and down (the image is the same width as the screen so horizontal scrolling isn't necessary). I've managed to do it but there's one problem. The image I chose is 640x4000 so that it'd fit the screen width perfectly and have enough room to scroll a bit. I made the scroll area the same dimensions. Then when I run it it ends up being 2x the width of the screen. I "fixed" it by halving the scroll area and the image size but why can't I get it to build it at retina display resolution? Is there a simple switch I'm missing?

    Any help would be appreciated.
     
  2. SimonBS macrumors regular

    SimonBS

    Joined:
    Dec 30, 2009
    #2
    For retina you should have a seperate image with double the size. You should name it the same as your original image with the extension of "@2x.png" (eg. myImage.png and myImage@2x.png)

    Please correct me if I am wrong.
     
  3. Kahnyl, Mar 21, 2011
    Last edited: Mar 21, 2011

    Kahnyl thread starter macrumors 68000

    Joined:
    Feb 2, 2009
    #3
    :D It worked. Excellent. Thanks a lot. Appreciate it.

    EDIT: Actually I'm just having one weird problem. To test what you said I made two pngs that were identical to the ones I was using previously. They were both blank with the text "1x" or "2x" on them. I quit XCode and replaced the original images in the project folder. When I restarted it showed the new plain images and when I ran it on the device I saw "2x" and I knew it worked. Then, I switched them out again for the old ones. Now, the device continues to show the plain "2x" image when I run the app. This image is completely deleted from my system (AFAIK). IB shows the correct images and the correct one shows up in the simulator. But when I run it on the phone I get the wrong image. Just in case it was cached I deleted the app from the phone and restarted. It still shows up. Any ideas?

    EDIT: Well, renaming the images and readding the 1x to UIImageView worked.
     

Share This Page