2
votes

I have long across many questions and answer regarding element settings for old and new iphone screens and got some idea as well. I have a query...I am preparing an app for iphone 320X480(iPhone), iphone retina 3.5 inch and 4 inch retina screens. For an instance of window (background) which I want to set programatically. It has to with a titlebar. so what I have done so far checked the screen size with

    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f) {
       UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
    [self.view addSubview:backgroundImage];
    [self.view sendSubviewToBack:backgroundImage];
   } else {

    UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Do.png"]];
    [self.view addSubview:backgroundImage];
    [self.view sendSubviewToBack:backgroundImage];
   }

First block would check for iphone 5 screen (I presume) and second would set screen for normal and retina both screen for which I put 320X480 px image name Do.png and 640X960 image name [email protected]. The iphone and iphone 3.5 (Retina) displays well on simulator however iphone 4 (Retina) which I presume will be equal to iPhone 5 does not displays correctly. Please let me know what should i do...and yes [email protected] is 640X1136....

1
Yes [email protected] is 640X1136....Vishal
add also this in your App then it show iPhone-4 retina images correctly...Vishal
I didnt get you...I have already added the code and image ...I mean I have got three images not Do, Do@2x and Do0568h@2x....Saty

1 Answers

0
votes

use the below method to set the size of screen

- (void)iPhoneDeviceScreenSetting {

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 480)
        {
            // iPhone Classic
            lowerImgVw.frame = CGRectMake(0, 395, 318, 40);
        }
        if(result.height == 568)
        {
            // iPhone 5
            lowerImgVw.frame = CGRectMake(0, 480, 318, 40);
        }
    }
}