开发者

More iPhone 4 resolution scaling fun

So I have two images set to fill the screen - one at 320x480 (iPhone 3) and the other at 640x960 (iPhone 4).

img.png      (320x480)
img@2x.png   (640x960)

In Interface Builder, I have img.png set to fill the view (it shouldn't be filling the iPhone 4 view, though, right?), and when I build and run, it is notably too small.

So, when I do the opposite, setting img@2x.png as the img, a giant blue question mark fills the view. The project still builds and the image fills the scr开发者_如何学Pythoneen, but is very pixelated as if it has been rescaled. It shouldn't have been rescaled, though, as it is the higher resolution.

Now using...

img.png      (640x960)
img@2x.png   (320x480)

I've also tried switching which file takes the @2x suffix, but that has not helped either. With the smaller file taking the @2x suffix, and setting the image view to img.png, it shows up way larger than the view canvas, but way too small when on the phone. With the smaller file still having the @2x suffix, I tried switching the view to the new img@2x.png and once again got the oversized, pixelated question mark in IB and a low res full-screen image when deployed to the phone.

I also made sure that my view size was set to 640x960 in the size inspector. What else should I be doing?


Don't use @2x when specifying the image name. Just use the base name of the image (so in your case, just img). iOS will do the magic behind the scenes to use the 2x version if it's on a retina display and the regular version otherwise (including when you use a xib to lay out your interface).

The displayed dimensions of the image will always be the dimensions of the non-2x image. The retina display just displays 2 pixels for every 1 which is why the scale is 2.0 and you have to double the dimensions of the original image. So your view size in IB should be 320x480.

Edit

If IB is being finicky, especially in Xcode 4, just try deleting the xib and starting over. Sometimes it gets a bit corrupted and doesn't know what to do with itself. I've had to do this on one or two occasions, and it seems that it worked for the OP as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜