Am I using AutoLayout correctly? (Screenshots inside) - ios

So basically I'm designing a layout for my app and I have difficulties adjusting my layout for iPhone 4. For an example look at these screenshots:
As you can see it barely fits on the iPhone 4 and the iPhone 6 has a blank space on the bottom. Am I using Auto Layout incorrect or is this the intended behaviour?
I also struggled not being able to make text fields smaller to fit the iPhone 4 screen in another layout.
Help would be much appreciated!

if you embed all views in a UIScrollView (with autolayout set), your content will be always visible(scrollable)
if you use size classes, you can set a specific UX for iPhone4

Related

Layout missed up on 3.5" Screen iPhone 4

I have developed my App on XCODE 8 which by default removes iPhone 4 emulator and I didn't notice that until I finished my app, and I used Auto layout to make the UI fits all iPhone screens and that what happened (the layout was good on iPhone 7,6,5) the problem is when I additionally installed iPhone 4 emulator I found that the layout is totally missed up and unreadable/usable.
So what options do I have to solve this and make it fit the iPhone 4 screen too with Auto-Layout with missing up the other sizes ?
Here is screen shot of my Login screen on iPhone 6 (4.7") vs iPhone 4 (3.5")
You must always give constraints with respect to other alternative buttons or a view, it should not be hard coded. Try making views programatically, it will be more easy and helpful to you.
It seems like your constraint is set to have a fixed distance related to the top of your screen. So when the screen height get smaller, your views are pushed out of the screen. So to better adjust views position, you can have your views to be related to vertical center. Say your login box is in both horizontal and vertical center, not metter you are using iphone 6 or 4, you should always see your login box.

The best way to make a viewcontroller for different screens

I would like to know which is the best way to make a view controller for iOS 9 swift 2 xcode 7, for different iPhone screens?
I have tried to make it with constrains but from iphone 4s to iphone 6s screens we can see wide gaps between the icons and text fields etc.
What i'm thinking is to make different view controllers for each screen (5.5inches, 4.7inches, 3.5inches) and to make my app check with which screen the user is opening the app and load the unigue view controller for this screen.
Or maybe there is a better way but im new to swift 2.0 so i'm asking for your help!
Thanks a lot for your time.
You can make a views for multiple screens using autolyout and size classes. You have proportional constraints that fit on all screens.
Proportional constraints means you can set for example view1 is 50% of screen.
These constraints fit on all screens.
Avoid excessive use of size classes (applying constraint in different size class). Try to go with proportional constraints in hAny wAny layout.
Only go for different size class if design on ipad is different then iphone. Or if you need different font sizes on different devices.
https://developer.apple.com/library/ios/recipes/xcode_help-IB_auto_layout/chapters/EditingConstraintAttributesintheAttributesInspector.html
I think this depends upon what your requirement is and what you prefer.
I usually prefer the good old Springs and Struts.
They can be used by disabling auto layout and screen sizes.
Using Springs and Struts i only create a single Storyboard to manage all iPhone and iPad screen sizes without any coding effort.
No matter how complex the UI maybe, for me Springs and Struts are the best solution.
Size classes give you a more fine grain control for different sizes and orientations. Please refer Apple's documentation
As I understood your question that you want to load storyboard as size of screen of device.
I will suggest you to refer this link to load a different storyboard depending on screen size. Sorry for Objective c but hope it helps you.
Load different storyboards

iOS 8 auto layout? Do I need it?

Is there a way to have an app work on all tall iPhone devices (portrait mode) without using Auto Layout?
Can I just design for say iPhone 5 and have iPhone 6 and iPhone 6 plus stretch to fill.
Auto layout seems overkill when I don't need to design for landscape or iPad.
Any ideas?
Auto layout seems overkill when I don't need to design for landscape
or iPad.
That's definitely not true. You could argue it was true before the launch of the iPhone 6, but even with only iPhones 4 and 5 it helps to account for different situations.
Can I just design for say iPhone 5 and have iPhone 6 and iPhone 6 plus
stretch to fill.
Stretch to fill is something that you can easily achieve with AutoLayout.
I know it seems a bit tough at first, but it's actually based on really simple mechanisms and behaves very logically. It's definetely worth giving it a try, you'll get much more out of it than you might expect right not.
Although Auto layout is optional, but to me it is a recommended feature.
Once your design become complex, you would have to write a lot of code to support different screen sizes. This can be avoided by using auto-layouts.
Yes you can in Show the size inspector-> Autoresizing. But you have to do it for each subview for each .xib file or in storyboard

iOS 8 AutoLayout: dilemmas with centring UITextView

With all these different screen sizes in iOS 8, I'm having an Auto Layout dilemma trying to centre this UITextView to display properly on all the different sizes of iPhone.
I've tried using various constraints - but I am still clueless on how to achieve my desired result.
This is where I am without applying any constraints.
As you may be able to see, I'm using a universal storyboard and I am trying to cater for 3.5, 4, 4.7 and 5.5 inch devices.
I recognise that I must apply some sort of constraint or alignment to universally centre the UITextView - my question is what should I do to achieve this?
Ultimately, is there a method that I can employ for my storyboard content to be scaled proportionally on all devices, avoiding this issue of variated alignment on different screen sizes? I'm having a similar problem on my other UIViewControllers, to display UIKitelements in proportion to as seen on the storyboard. Any help would be much appreciated, thanks!

UIViewController Size doesn´t work

Hi im currently developing an Universal app for iPhone, iPod and iPad. I have all view controllers in both storyboards set to Inferred. It works fine on iPhone Retina and on all iPads but when you put it in landscape mode it gets all messed upp and on the iphone 3,5 inch simulator the bottom gets cut off. How can i fix this? Do i have do create seperate view controllers for landscape mode and iphone 3,5? And the write some code that recognizes if its in landscape mode and iphone 4? I thought this worked automatically. Or have i done something wrong?
There is no quick fix/answer to your question.
Since the screen size is different while using horizontal and vertical orientations - it is simply not the same canvas and thus you will need to do some manual work to set it right.
Strategy 1.
Assuming your layout is simple - there are not too many elements and all elements can theoretically fit both horizontal and vertical screen size:
You should use auto layout from the Interface builder - Look at an excellent video from WWDC
https://developer.apple.com/wwdc/videos/
(video 406 - Taking Control of Auto Layout in Xcode 5)
In few words - you set spacers to your elements, aligning them to the end of your view (dynamically), therefore you can make your element shrink and move automatically respecting the current screen orientation.
Strategy 2.
Assuming your UI is complex and will not fit both orientations:
have a different xib file for horizontal and vertical views, this can take some time, but it is a solid solution that always looks good.
You simply need to track changes in orientation and load the appropriate xib.
Your problem will only be solved if you use Autolayouting and for that you need to go through some tutorials
Ray's Tutorial
Another Very well explained tutorial
Going through the above articles will definately help you in solving your problem

Resources