Autolayout change height of the view when app starts - ios

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.

Related

how to put screen size and uiview in ratio format to work for all screen

i have 2 UIView in horizontal view. its both UIView size is 141 x 192.when i run in 5s screen the two view are in perfect. But when i run in 6,6s my UIView width is stretched. not able to see the correct width.
so how to code - use the screen size and display the correct width and hight equal for all screen using objective c
i used storyboard to fix 2 UIView. i am new to ios. how to code the UIView with position and also the aspect ration of screen size to see my UIView equal for all screen
You can use autolayout and size classes for making user interface for multiple screen. First enable autolayout and size classes
Then you can give your views proportional width and height. For example in your case both view width will get 50% of screen width.
Since this is very detail topic. I will share a very simple and beginner tutorial.
http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
Follow the tutorial and learn how to use autolayout.

How to handle iPhone 4s, 5 and 6 screen size, and make all the contents look the same across al the devices

I am using Xcode 6.1 and in one of the views I have, contains many labels. However, these labels look different in each different devices. Although I have add constraints to all the labels, but still facing the same issue.
How can I get the same view layout across all devices?
How can I make the width and height for each label is flexible, depends on the screen size?
Do I need to design different xib for each device?
The following images showing the result am getting, with auto resize enabled, and constants been added.
on iPhone 6
on iPhone 5
on iPhone iOS 7.1
We have provided with a simple solution . Using Aspect ratio constraint we can get a relative look in all device screens.
I had the same issue and I found this >>
http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/
So when designing for lowest to highest screen resolution we can't set a specific width and height for all controls as it may look weird. So using this constraint we can have a relative look for all screens.
If you don't want to use constraints or you want to keep the same width & height , you can add scrollview to hold all controls. For that you can set a resizing frame for scrollview with fixed content size .
To solve this...
1) Go to xib file and uncheck the Auto layout
2) Then set the autosizing manually in the following manner for each and every subview.
Use self.view.bounds.size.width to get the width of screen, then use relative value to initialize all labels.
One soultion is that you can Design a story board for each screen size like one for iphone 5, one for iphone 6 and one for iphone 6+ and in your AppDelegate method "didFinishLaunchingWithOptions" you can get the screen size and popup corresponding storyboard
in this wasy you can set different constraints according to different screen size

ImageView width more than cell width in UITableView Cell - XCode 6

I am developing an application in XCode 6 for iOS 8. I am not using auto-layout. I am trying to put an ImageView in a UITableView cell. When i run the app on iPhone 6/6 Plus:
The size of the imageView becomes double than my cell size if i check all the auto-resizing options.
The size of the imageView becomes lesser in width if i uncheck all resizing options except for the left one.
Is this some bug in XCode? Because I think, if i check all the auto-resizing options, and use scale to fill for the imageView, it should scale up and down accordingly, rather than going out of bounds of the view and cell.
All help is appreciated.
I ended up finding out that it all depends upon the splash screens you have added. AutoResizing proves troublesome on iPhone 6 and 6+ if you have splash screens for them.
But if you remove those splash screens and only keep a splash screen for iPhone 5, then your app will properly scale up and down, hence the bug will be resolved.

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.

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

Resources