0

I have created an app using ios 5 ,and all the user interface are created for 320*480 resolution ,and now I am trying to run this app in iPhone 5 ,than all the control's that I have created using IB is not display properly placed I have checked tutorial on mobiletut how to creat in iphone 5 user interface, but it only give solution for controls that created programmatically ,and not for the controll created by IB,so any help on this topic.

iphone 4s image:

enter image description here

iphone 5 image:

enter image description here

please ignore little image problem in iphone 5 img,i am constructing image which have resolution 640*1136.

  • Read this: http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution – lakshmen Feb 20 '13 at 10:31
  • @lakesh, i have tried this line, ".3 Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly.",but it's also not displaying my controlls at proper place, could you point me to some tutorial about auto resizing masks. –  Feb 20 '13 at 10:34

4 Answers4

0

It seems that you must set a launch image for the 4-inch display in order to work if you are coming from a 3.5-inch display project.

enter image description here

apascual
  • 2,970
  • 1
  • 20
  • 32
  • no i have solved that problem using Default-568h@2x.png image but i want solution for controls.that not display in perfect place in iphone 5. –  Feb 20 '13 at 10:30
  • Can you show us an example? An screenshot would be perfect... You'll probably have to set correctly the struts in your storyboard files... – apascual Feb 20 '13 at 10:31
  • It seems fine to me, where is the problem? – apascual Feb 20 '13 at 10:48
  • see there place bellow submit is larger than iphone 4s screen. –  Feb 20 '13 at 10:51
  • but if i change anything in IB than it will also affect 4s screen which i dont want so i want middle solution that my app will display perfect in both screen. –  Feb 20 '13 at 10:52
  • Ok, now I see what you mean... In my opinion, the only way to have a perfect positioning in all the different screens is to set it up programmatically. Anyway, for this concrete case my recommendation is that you remove all the Autosizing options in Size Inspector and try to center the components vertically... – apascual Feb 20 '13 at 11:05
0

You have to set the Default launch image for Retina 4 inch, as apascua said.

By the way in my opinion to manage multiple interfaces for iPhone 4 and iPhone 5 the best solution is to create two different xibs, one called MyView_iPhone5.xib and the other called MyView_iPhone4.xib and manage it through an Utility class which method returns the correct xib name based on device the app is running.

Check this gists :

https://gist.github.com/andrealufino/4994648

When you need to call you nib you can use this line of code

MyViewController *controller = [[MyViewController alloc] initWithNibName:[Utility nibName:@"MyNibName"] bundle:nil];
Andrea Mario Lufino
  • 7,921
  • 12
  • 47
  • 78
0

I faced the similar problem like this.

This is how I solved the problem.

1)Place the Default-568h@2x.png

2)Set a property for an imageview and synthesize it and it is an IBOutlet for the imageView and connect it.

3) in the viewdidload function

an example:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
        // code for 4-inch screen
        _backgroundimageView.frame = CGRectMake(0,0,320,460);
        [_backgroundimageView setImage:[UIImage imageNamed:@"image1-568h@2x.png"]];
    } else {
        // code for 3.5-inch screen
         _backgroundimageView.frame =CGRectMake(0,0,320,370);
        [_backgroundimageView setImage:[UIImage imageNamed:@"image1.png"]];
    }

When you add Default-568h@2x.png, both the tab bar and navigation bar will move down andup respectively. Left in the center image.. resize it..the Hope this helps..

lakshmen
  • 28,346
  • 66
  • 178
  • 276
  • my problem is not background image but the controll which is button textview and label that not place at perfect place in iphone 5,like iphone 4. –  Feb 20 '13 at 11:24
  • the concept is similar. I have done for an image. You can do it for a button, textview or label. Set the frame of the item accordingly. – lakshmen Feb 20 '13 at 14:53
0

in iOS 5 you can use the Size panel in the Utilities toolbar to set the distance or size of controls as the view controller changes size.

xCode ScreenShot

If you change the I, it fixes that distance from the top or sides of the screens. By changing the arrows, it will resize as size of the screen changes size.

You will want to set the AutoSizing to display as it is in the image below, and you should get what you want.

If you place your mouse over the example image on the right you get a preview of what it will look like as the view controller expands and shrinks

For iOS 6 apps you should be using constraints. There is a really good article at http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

Marryat
  • 535
  • 3
  • 11