Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewControllers not resizing for 3.5 inch screen

I'm really struggling with this one. I searched this issue all over but no one seems to experience exactly the same problem.

So I have this ios7 project, which should run on both 4 and 3.5 inch devices. On 4 inch, everything is fine, but on 3.5 inch view controllers have frames height of 568

If i log the UIScreen bounds in AppDelegate, it returns correctly 480. But if i create UIViewController and add it as rootViewController to NavigationController, its height is 568. (NavigationController has too a proper height of 480)

First, I thought it may be because of XIB, so i created blank UIViewController just by [[UIViewController alloc] init], but it still has height of 568.

This is driving me crazy, because my other project works fine this way and viewcontrollers are resized automatically.

I checked i have a proper starting images defined in images.xcassets, and i tried XIB both with and without autolayout.

Only one thing helped, if i turn simulated metrics in xib to NONE or 3.5 inch, but then i dont get fullcreen on 4 inch. And having multiple xib for both screens is not solution for me.

Any hint would be greatly appreciated

Thanks

like image 392
r2d2 Avatar asked Nov 17 '13 17:11

r2d2


2 Answers

I was currently facing this problem as i am using the autoLayouts but now I have resolved this issue using nib. So i want to share it with you.

If you are making a viewController through nib. Then you should make sure that "Resize View From NIB" is checked . After doing this you will get the frame height of the view w.r.t screen bounds. ( in 3.5 inch screen it will be 480 and in 4 inch it will be 568).

enter image description here

like image 183
Sohaib Muhammad Avatar answered Nov 02 '22 15:11

Sohaib Muhammad


This happened to me except it was the other way around - the app ran on the 4 inch with a 3.5 inch screen.

The trick is your launch images. Make sure that your R4 image is actually for the 4 inch and the @2X Image is for the 3.5 inch.

like image 1
Daniel Galasko Avatar answered Nov 02 '22 13:11

Daniel Galasko