tags:

views:

87

answers:

1

Hi,

I am very new to iPhone development, and I am working on modifying an app which was written a year ago. Recently with the release of the new iphone 4 we have noticed that the screen which was previously displaying an image just fine, has not started to tile that image. And instead of one large image I am now seeing 4 smaller ones. I have tried increasing the size of this image but that does not help. Anyone know what this can be? Resolution? How do I fix this?

Thanks, Natasha

A: 

You need to create another double-resolution version of the file with @2x in the filename. For example, if your original graphic is

tile.png

You need to create your double-resolution one as:

[email protected]

This will be used on the iPhone 4 and should fix your problem.

Update

If you have no control over the images you will have to detect whether you are running on a high-resolution device and set the contentScaleFactor property on the image appropriately. Something like this:

UIScreen *screen = [UIScreen mainScreen];
if ([screen respondsToSelector:@selector(scale)] &&
    [imageView respondsToSelector:@selector(setContentScaleFactor:)]) {
    /* Set image view's scale factor to that of the native screen */
    [imageView setContentScaleFactor:[screen scale]];
}

This uses an imageView, but it sounds like in your case a view is using a [UIColor colorWithPatternImage:...] on its background, so you may have to set the scale on something else. This might affect the position of subviews as well.

Why are you not able to create a new @2x version of the image and include it in your bundle?

Mike Weller
I have no control over the images, is there anything else I can do form code side?
Natasha G
See my updated answer
Mike Weller