0
votes

I'm working on app and need to support iPhone 5's 4 inch screen sizes. I initially designed the app and ran thru the XCode 4.6 simulator targeting iPhone 3.5 inch (retina and non retina displays) and switched to iPhone 5 from within the simulator. To my surprise, I was seeing a 1 inch space at the bottom of the screen beyond my several UIButtons. I have to scroll on the iPhone 5 simulator to view my UIButtons. What should I do here to support all screen sizes and make it look identical on all devices?. Also, my app only supports portrait mode for all devices (including all revisions of iPad) and I'm not using storyboards at all.

Please help.

1

1 Answers

0
votes

You can't make the 3.5 inch screen and the 4 inch screen look identical because they are not. But you can make it look better on both. It's hard to tell what problem you're having without seeing the code. But I'll take my best guess to help you out.

If this view is part of a viewController that you've added as the rootViewController, then it should take care of expanding itself to fill the full screen, no matter what size the screen. However, if this is a subView within a viewController's view, then you should ensure that the view takes up the full screen. Often people hardcode the frame of the view to arbitrary numbers like so:

[view setFrame:CGRectMake(0,0,320,460)]; 

However, that is not portable between 3.5 and 4 inch screens. You want to do this:

[view setFrame:self.view.bounds];
[view setFrame:self.view.window.bounds];  //sometimes i use this instead

//set autoresizing
view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

Apart from that, you can also use autoresizing to anchor components to the bottom of the screen, or to resize along with height of the screen.

See this post for how: How can I stretch and anchor a central view between a fixed-height header and footer, using Interface Builder?