0

I am using both device for make my application.my application is perfectly run in iPad but when i select device as iPhone 4inch there is an error occur in interface.below is picture. you can see black color in top and bottom where did it came from?

enter image description here

and here is my code:

in app delegate:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
    {
        NSLog(@"Ipad ");
        [application setStatusBarStyle:UIStatusBarStyleLightContent];

        self.window.clipsToBounds =YES;

        self.window.frame =  CGRectMake(0,-20,self.window.frame.size.width,self.window.frame.size.height+20);
    }
    if
     (IS_IPHONE_5)
    {

        NSLog(@"Iphone %f ",[[UIScreen mainScreen] bounds].size.height);
        if ([[UIScreen mainScreen] bounds].size.height == 568) {

            [application setStatusBarStyle:UIStatusBarStyleLightContent];

            self.window.clipsToBounds =YES;

            self.window.frame =  CGRectMake(0,-20,self.window.frame.size.width,self.window.frame.size.height+20);
        }
    }

}

enter image description here

3 Answers3

2

If you want to support app for iPhone 5 screen. You should add image which enable app for iPhone 5 screen size. This should be implement from xcode 4.5+

Add this image to your project Xcode screenshot. To enable your apps to work with iPhone 5, you need to add a retina version of the launcher image. It should be named Default-568h@2x.png

Set the autoresizing mask of the center content to expand in both directions.

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

Otherwise you can change view size by below code which will make you screen to compatible with your iPhone 5 screen.

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
    // code for 4-inch screen
} else {
    // code for 3.5-inch screen
}
Mani
  • 17,549
  • 13
  • 79
  • 100
  • i didn't get you please explain in detail. – user3218052 Feb 21 '14 at 06:23
  • I think it's correct. Else, you've to workaround to achieve what you want. Because you may face other issue with IOS6 devices with 3.5" screen!! Check it out and start fix issues with it. – Mani Feb 21 '14 at 06:52
  • you think its correct but if i want to remove navigation bar than i also code for hide navigation bar.please give my an appropriate solution. – user3218052 Feb 21 '14 at 06:56
  • see these links http://stackoverflow.com/questions/2926914/navigation-bar-show-hide ,http://stackoverflow.com/questions/9239067/how-to-hide-a-navigation-bar-from-one-particular-view-controller, http://stackoverflow.com/questions/6544966/hide-navigation-bar I think, it will surely help you. – Mani Feb 21 '14 at 07:32
1

If you want to use compatible for both iPad and iPhone(standard, 3.5 inch, 4 inch), try this

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
    if ([UIScreen mainScreen].scale == 2.0f) {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        CGFloat scale = [UIScreen mainScreen].scale;
        result = CGSizeMake(result.width * scale, result.height * scale);

        if(result.height == 960){
            NSLog(@"iPhone 4, 4s Retina Resolution");
        }
        if(result.height == 1136){
            NSLog(@"iPhone 5 Resolution");
        }
        else {
            NSLog(@"iPhone Standard Resolution");
        }
    }
    else {
    //iPad
        if ([UIScreen mainScreen].scale == 2.0f) {
            NSLog(@"iPad Retina Resolution");
        } 
        else{
            NSLog(@"iPad Standard Resolution");
        }
}
shankar
  • 632
  • 4
  • 14
0

Add a Default retina image for iphone 5 640*1136

sabeer
  • 603
  • 10
  • 28