0
votes

I have to display the same image in iPhone and iPhone(3.5 retina inch). But it appears differently.

The original image looks like this:

enter image description here

It runs correctly in iPhone but it doesn't run correctly in iPhone(3.5 retina inch). In iPhone(3.5 retina inch), it appears like this:

enter image description here

I have tried this:

imageView.contentMode = UIViewContentModeScaleToFill; 

The whole code looks like this:

if(IS_IPHONE_5)
    {
        // code for 4-inch screen
        backgroundImageView.frame = CGRectMake(0, 0, 320, 460);
        backgroundImageView.image = [UIImage imageNamed:@"image1_iphone5.png"];
   } else {
        // code for 3.5-inch screen
        backgroundImageView.frame = CGRectMake(0, 0, 320, 370);
       backgroundImageView.contentMode = UIViewContentModeScaleToFill;
        [backgroundImageView setImage:[UIImage imageNamed:@"image1.png"]];
    }

but this doesn't solve the problem. Have been stuck with this issue for a day. Not sure what the problem is. Really need some guidance.

1
CGRectMake(0, 0, 320, 370) seems to be problem.....change rect exactly as of image resolution and it should work.... - Mohammad
the size is 640 x 733.. how to show the exact image? I need to resize right? even if that was the problem, i should have been a problem for iPhone as well. - lakesh
Various screens have various DPI values. Thats why apple recommends different images for different phones. see this developer.apple.com/library/ios/#documentation/UserExperience/… - Mohammad
huh? I dun understand you. - lakesh
Override drawRect method and use [img drawInRect:rect]; to draw the image. - kaar3k

1 Answers

0
votes

If you have one image for 4-inch and 3.5-inch devices the problem is probably in autoresizing mask, looks like now you have UIViewAutoresizingFlexibleHeight on. Try setting UIViewAutoresizingNone instead.