Problems with layout of 3,5 inch iphone screen - ios

I'm trying to add an iAd banner which I set just above a UITabBar, and it works perfectly on 4 inch screens, but when I test it on 3,5 inch the banner is totally invisible.
Is there a simple way to fix all the views so that everything will be scaled to the 3,5 inch screen if needed?
I've found a tutorial saying to set the "size" of the "Simulated Metrics", under the Attribute Inspector of the view to freeform, but it doesn't work.

You need to specify constraints for how all of the screen contents moves or resizes and the available space changes. The banner view need to be pinned to the bottom and you will need a view somewhere to be pinned to other views but have a flexible height.

Related

Autolayout with subview screen issue different devices

I have designed simple one page design for universal application. so I had faced issue while checking the 4 inch devices its working fine. other than 5.5 to above devices its not looking good.
View(MAINVIEW)
ScrollView
View
Label
..
..
above I have mentioned the structure of the page.below I have mentioned screen shots.
above Screen shots image I have designed. with all constraints.
after that I have checked the preview of the page design.
Iphone 4-inch its showing fine. but Iphone 5.5 its showing in bottom not filled whole page view.
It looks like then you have set the height constraint for ScrollView or view. If you did this then remove that height constant and set the bottom constraint which should have 0 constant value to its superview.

Why do the layout positions change in preview when I simply add a new screen size to the preview screen?

I have a 4 inch screen displayed in Assistant Editor Preview while I'm adding constraints to the view controller in Storyboard. Once I get everything situated in the correct position with the constraints and the layout looks good on the 4 inch screen, I then add another screen size to the preview window. For some reason, just by adding another screen size to the Preview window causes the layout preview on my perfectly good 4 inch screen to slightly be changed. Is this odd behavior or am I doing something wrong?
I had a similar issue, but instead with the 4.7 inch screen size. I found that using 2 things helped me keep the layout and constraints consistent across all screen sizes.
First, keep your storyboard default layout to universal (square) so the constraints aren't applied to one screen size only.
Second, when setting your constraints, use the "Reset to suggested constraints" button located on the third constraints tab.
I have yet to experience layout issues using this method. Hope this helps!

Auto layout isn't working as expected for laying out buttons?

I'm creating a scene in XCode in Main.storyboard where the user is able to choose between 5 options (buttons) and when I created the auto layout to horizontally center the buttons, as well as vertically space them 5 pixels apart:
On the 3.5 inch screen, the buttons take up most of the screen
On the 4 inch screen, the buttons take up about 3/4 of the screen
On the 4.7 inch screen, the buttons take up about half of the screen
It makes sense for this to be happening, but I created a #3x, #2x, and normal sized (1x) images using Prepo
The buttons have custom background image properties
How can I get the 4 inch, 4.5 inch, and even 5.5 inch screens on the iPhone to display like the 3.5 inch screen where the buttons take up most of the screen?
Set the following constraints for your buttons.
For 1st button set constant top space to top layout guide (say 20px).
For last button set constant bottom space to bottom layout guide (say 20px).
Set equal heights for all buttons.
And you already have the following constraints.
align buttons horizontally centre
vertical spacing between them is 5px
So now buttons will adjust its height to take up most of screen space.
Try this.

Centre relative to height when on 3.5 inch iPhone

Ok, so I want the positioning of the items in a view to re centre when going from 4 inch screen to 3.5 inch screen. How do I do this.
I've attached pictures for what it looks like on a 4 inch screen and what it looks like on a 3.5 inch screen.
Image 1: http://i.stack.imgur.com/P2KtI.png
Image 2: http://i.stack.imgur.com/V1TLb.png
So image 1 is the 3.5 inch version and 2 is the 4 inch version. As you can see on the 4 inch screen, all the items in the view are in the centre relative to the height. I want it to be in the centre for the 3.5 inch screen as well. How do I do this with autolayout?
If you're programmatically implementing the objects you could easily change the placement for the screen size based around the self.view.frame.size.height. You could take that information and correctly place your objects in the center by doing some basic math.
If you're using storyboards you can use autolayout to set constraints in IB to have all of the items stay where you want them relative to the screen size. When you select an item on your scene you can easily add autolayout constraints by going to Editor -> Resolve Autolayout Issues -> Add Missing Constraints.
Remember that if you are using storyboard's you can change which screen size you're viewing. In the bottom right of IB there are a selection of buttons and the one on the far left toggles between 4" and 3.5" screen sizes.

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.

Resources