-6

My App is working fine in iphone 4, but in iphone 5 it is showing the bottom screen empty. And i think it is because iphone 5 has larger screen, so what is the solution to it, how to manage that extra space. Please guide for the above.

Thanks in advance.

iPhone Programmatically
  • 1,211
  • 2
  • 22
  • 54
  • 2
    http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution – nsgulliver Mar 11 '13 at 11:40

6 Answers6

3

Use this code it will help you, here we have to create two xib file for using this code like (viewcontroller.xib and viewcontroller_5.xib),when you use the application in iphone4 call iphone4 screen else call iphone5 screen.

Thanks.

if([[UIScreen mainScreen] bounds].size.height == 568){
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_5" bundle:nil] autorelease];

   NSLog(@"iphone5");
}else
{
  self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    NSLog(@"iphone4");
}
maddysan
  • 258
  • 2
  • 14
2

If you are using iOS 6 or later , then u can create a separate xib for the iphone 5 called Retina 4 Full screen. You need to check this in your ViewController Size. Also to check for for both of these xib's . That means to run either of your xib's in iphone 5 or lower versions use these conditions whether in the AppDelegate or wherever you need to show another ViewController.

CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
}
else if(result.height == 568)
{
}

the above code would check for the size of your iphone's screen and accordingly adjust. Hope this has cleared your issues :).

PS:- Dont forget to add your iphone 5 splash screen i.e Default-568h@2x.png.

IronManGill
  • 7,222
  • 2
  • 31
  • 52
1

According to me the best way of dealing with such problems and avoiding couple of condition required for checking the the height of device, is using the relative frame for views or any UI element which you are adding to you view for example: if you are adding some UI element which you want should at the bottom of view or just above tab bar then you should take the y origin with respect to your view's height or with respect to tab bar (if present). For such cases where you are putting images as background for full view then you can set the Image as the background colour for the view.

self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"IMAGE TO BE ADDED"]];

0

Try this for any controller,

enter image description here

So, it'll automatically resize window according to height.

For, retina(iPhone-5) display, you must import "Default-568h@2x.png" file in your xcode project.

Hopefully, it'll help you to understand.
Thanks.

Manann Sseth
  • 2,745
  • 2
  • 30
  • 50
0

Add the same splash screen image as used for devices below iPhone 5 but with image size 960 * 1136 and the name as Default-568h@2x.png i.e if Default.png is currently the splash screen. This shall provide iPhone 5 screen support to your application.

AppleDelegate
  • 4,269
  • 1
  • 20
  • 27