iOS 8 AutoLayout: dilemmas with centring UITextView - ios

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!

Related

Issue with UIView on IPhone 7plus and 8plus

UIView on IPhone plus stretched and normal on regular sized iPhone. Constraints are all done in story board. I’m not sure what I’m doing wrong. Please help. Attached are imaged of the views : iPhone 7 Plus and iPhone 7.
I figured my issue was with my misunderstanding of auto layout, which is why I was not able to get my uiview to adjust properly across different screen sizes. This tutorial on youtube really broke down auto layout in such a simple way. Check it out (link below). I hope it helps someone else out there. thanks!
"Auto Layout Tutorial in Xcode with Swift for iOS 11 | iOS Development Tutorial"
Your problem is in the bottom constraint because of different screen heights you get different height for the view as the bottom constraint is static (528) , so to fix that remove that constraint and give it a static height or proportional to screen height
Also remove one of the top constraints as setting 1 is enough

Am I using AutoLayout correctly? (Screenshots inside)

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

Building responsive layouts with AutoLayout

For the past few months, I have been trying to learn iOS development. Most of it has relatively easy, however, one thing has been very difficult for me. AutoLayout. After I grasped constraints, I thought it would be easy, but I am having real trouble getting my layouts to look well on both iPhone and iPad devices. I can design pretty well for iOS. Recently, I was building an app where I put two buttons in the ViewController. on iPhone, I set the constraints of the buttons to equal the width of the screen (plus the screen margin), and set a reasonable looking height to the buttons. On iPhones, my layout looks great, but on iPads (especially the newest iPad Pro), things look horrific. Full width buttons look great on the iPhone, but on iPad they need to be a lot smaller width wise and a lot bigger height wise. Likewise, my images look great on iPhone, but are too small on iPads. In CSS, I could just use MediaQueries, and on Android, resource qualifiers on the values and layouts.
What are my choices here? How can I design my layouts to look nice on both iPhone and iPad when certain dimensions need to be different based on screen size, screen resolution, etc.? Constraints seem to be good for enforcing dimensions, but not adapting them.(Except maybe the Aspect Ratio constraint)
What features of the AutoLayout system can allow me to accomplish responsive layouts among larger screens and Retina resolutions? What are some common tips / tricks for developing responsive layouts.
You can use size classes in order to build for different screen sizes easily. raywenderlich.com has a solid guide on adaptive layouts.
You can use size classes to design differently for iPhones and iPads and also you can use proportional width height to look perfect based on the height ratio of all devices. If you want to choose first option then you can go with any tutorial available but if you want to choose the second option which is the little difficult way but time saving way then you need to really understand the sizes of devices and need to understand what actually proportional width and height constraints do. Thanks.

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

Shrink white space within elements in a UIView for iOS 7 using Storyboards and Autolayout

I don't know if I can accomplish this because I can't find any information or tutorial doing what I need to do, and maybe this just can't be accomplish at all and I am wasting my time.
What I want to do is to shrink the white space between diffenrent element inside the same UIView for iOS 7 using storyboards and autolayout, so they can re-arrange themselves to fit nicely inside a 3.5 inch screen and landscape mode.
I've been working on this the last 3 days and no matter what I try to do with the constrains, I can't make it look the way I want it in landscape or 3.5 inch screen.
This is what I want!
Maybe some of you can give me some hint about it, or just let me know if I can even do this, because I'm out of ideas.

Resources