ViewControllers not resizing for 3.5 inch screen - ios

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

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).

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.

YOU get the size in wrong timing.
The initialized size is from NIB,
SO you need get the adjusted size in -viewDidLayoutSubviews (lower version in -viewDidAppear)

I had a similar problem. Turns out that I had a embeded segue and that the original container view was hard coded to 568:
Here
I am not sure if this will solve your problem, but something to look out for.

Related

UIScrollView constraints based off storyboard

I'm trying to have a pictures be part of a scroll view in a gallery. I added 4 constraints: aspectRatio, Center Vertically, and a -12 margin spacing to the nearest neighbor (the view) on the left and right side.
For some reason when the UIView in the Storyboard is a 4-inch iPhone the iPhone 5 and 5s are aligned and the 6 and 6s are messed up. If I change the UIView size to an 4.7-inch iPhone (leaving the constraints alone), the 5 and 5s are misaligned and the 6 and 6s are fine. I think the initial size of the scroll view is initialized when the view first builds itself which is initially in the size of your storyboard. So I tried printing out the frame to debug. When the iPhone in the storyboard is 4.7 inch the frame prints out to (-1,83,377,500) which works perfectly. When the Storyboard is a 4 inch the frame prints out (-1,70,322,427)
I tired using scrollView.layoutIfNeeded, which helps and prints (-9,72.5,393,522) but doesn't get the frame the same as if the Storyboard was set to the 4.7 iPhone.
Edit: Screenshots
Ah I solved it. It seems like I was calling scrollView.frame too early. Using it in viewDidLoad is too early it can't be used until viewDidLayoutSubviews(). Massive headache gone!

Autolayout change height of the view when app starts

I have UIViewController on storyboard.
On the image you can see top gray is simple UIView while bellow is UITableView.
And I set uiview to be 150 height.
I use autolayout.
Problem is that when I run app on iPhone 6 uiview height is about 40% of the UIViewController.
From some reason it's height is larger than 150.
Can somebody explain me how can I setup view so I have UIView always the same size?
I think the problem is with your view height....you can not give static height.... see the images and check out where you missing out....
and the o/p is in 4.7 , 5.5 , and 4 inch is
for all the height of view is looking same....that is of 150 height
Have you included an iPhone 6 launch image? My guess is that the iPhone is resizing up based on the resolution of the 4" screen. Include either a static launch image, or a dynamic, xib-based one, and I think that should fix your problem.

Why does my View frame size change when using Autosizing in Portrait mode?

I'm trying to understand how Autosizing works. After reading some posts like How to Automatically Resize a UIView When The Orientation Changes, iOS 4 iPhone Rotation, View Resizing and Layout Handling, Understanding UIView autoresizing, ...
I think that Autosizing only works when there is orientation changes so that the View can be displayed properly, but it doesn't. It does resize my View frame size either when I'm only in Portrait mode. Why is that ?
I cannot fully tell from your screen shot, but I assume that in your storyboard the view is in the 4 inch dimensions. Then you are using the 3.5 inch simulator. Since you have made your sizing constraints say in essence...
"Keep my view this far from the top and this far from the bottom, and resize its height to force this"... Your view will shrink that half inch to make sure it matches your constraints.
Try running it in the 4 inch simulator and see if that works.

How to make a view in a XIB/storyboard size to the phone dimensions without using auto layout

I have a scroll view in a storyboard and the app is to run on iPhone4s and iPhone5s with iOS5 and iOS6.
I initially created the storyboard and was running on an iPhone5 and now I'm testing with an iPhone4.
Isn't there a way of just using a single storyboard for both the iPhone4 and iPhone5 and the when views etc. will automatically resize themselves depending upon the device, or do I have to use two separate storyboards?
I've tried numerous things, such as changing the simulated metrics size and many others but I can't find anyway of the view changing its size automatically - as I created the storyboard initially for an iPhone 5 the view now seems stuck at a 548 height when loaded. SUrely there must be a way of specifying in the storyboard that its height comes from the device? (Its height is the full screen less the status screen).
Further details
There is UIScrollView inside a UIView, the UIView will resize, the UIScrollView will not:
Yes, you can do it in the "Size Inspector", inside the Utilities menu. There you can set the autosizing and origin of any visible element.
This works in iOS 5 and 6 and it's not required to use the Autolayout, which is only for iOS 6.
Size inspector:
Second screenshot:
You have to use two storyboards for iphone4 and iphone5. Then you can check the device size to load the .xib according to it.

Resizing UIScrollView for 3.5 and 4 inch screen sizes

I am currently working on updating my application to support the new 4 inch screen size. I am noticing a few UI issues, particularly with UIScrollViews. I would like to get a scrollview to stretch to fill the screen when there is empty space below it; whitespace is the result of the scrollview not stretching on the 4 inch screen size. Currently, I am adjusting the scrollviews frame during the viewDidAppear method of my VC to accommodate for this. However, I am wondering if it is possible to handle this through IB.
I have played around with the autosizing options through IB with no luck. I have also tried setting the size to the "Retina 4 Full Screen" option and am noticing the opposite, the scrollview is not shrinking to fit the 3.5 inch screen size.
There has to be a simple way of doing this through IB.
I have only been able to simply use a [UIScreen mainScreen].bounds.size.height attribute to set the size automatically, but that's pretty painless.
try something like this:
scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

Resources