Layout issue, Autolayout enabled but doesn't seem to work - ios

Below is my app when run on iPhone 6 simulator
As you might have guessed it looks good on iPhone 5.
Autoresize is on, but I'm not sure i fully grasp the concept, so i might be missing something.
Any suggestions for a solution are appreciated.
I also added another image for the storyboard structure.

It might be possible as you might have not set layout constraints. The below link will help you how to set constraints. In the below link i've used size class but it is not necessary for you to use sane view, similar constraints can be applied to the storyboard structure you have used.
Hi please visit below link:
iOS 8 Autolayout with Size Classes
Advance auto layout Constraints:
Adjust Center of Measure in Xcode 6

Auto layout is on but you are not using it. You need to add constraints so that when the main view is resized to fit the screen, the table view is resized along with it. Otherwise, it just stays at the same size you designed it (which happens to be the right size for an iPhone 5). These devices are different sizes; the idea of auto layout is to cope with that difference. Use it.

Related

Alignment Issue in AutoLayout in IOS Swift

I have 3 sections, Top Banner with Logo, Mapview in the middle and then a few labels under the MapView.
I have used Constraints for accomplishing this for 6s sizes. But when I try this out for 4s, 5, 5s the below section the Labels is not seen on the screen. In design view they are also only partially shown and seems to be somewhere hidden in 4 and 5 ios versions.
I have set height for the Top banner as 0.2 with the SuperView and MapView with 0.4 and trying to get the remaining labels to fill in the remaining 0.4 height of the total SuperView.
I have tried to contain all the labels in a Tableview also this is not even showing anything in Design time or even at runtime.
Another Approach is to Add a view in which place all the labels so that can add a contraint of 0.4 height for the view. But all in vain.
Layout Design :
http://imgur.com/aIjBJsq
I am an iOS and auto layout Noob so it maybe something silly that I might have missed. Appreciate any help or advise on the same
Ok, first it seems that you need a break down of the fundamentals of Auto Layout. Below are some resources that can help you with that. Working with Auto Layout can take quite a bit of effort so you really should get a solid understanding, otherwise you will constantly be running into problems.
Adaptive User Interfaces
Auto Layout Guide
View controllers and adaptivity and size changes
WWDC2012: Auto Layout by Example
WWDC 2015: Mysteries of Auto Layout, Part 1
WWDC 2015: Mysteries of Auto Layout, Part 2
Key to understanding your issues is the role layout constraints play in your design. You use them to make small to medium changes, for bigger changes such as different devices you need to use size classes as well as constraints. In Xcode 8's Interface Builder you have the option to set the device for your layout, see the picture below. It's in the bottom left-hand corner. The device's selection relates to size classes.
So how do we go about solving your issues? We would start by laying out the view for a selected device in interface builder, then we would select another device, say iPhone 4s and then make any adjustments to your view there. This is the basic outline and there are many steps in between. The single best step you can take at this point is to get a better understanding of Interface Builder. Learning how to use interface builder will touch on all the areas covered by the resources listed above.
Interface Builder
wwdc2015: Implementing UI Designs in Interface Builder
I understand this is a broad answer to your question, but I am trying to help you build an understanding of the concepts, so you can happily build your own layouts from here on out!

Steps to convert iPad app to universal, ideally with just one storyboard?

I've had several attempts to try and convert my iPad app to make it universal.
I'm only supporting landscape on iPhone / iPad.
My existing iPad setup uses a storyboard without autolayout, which works fine.
My app had lots of images and about 10 screen each with a minimum of 6 views on each, however some have 20 or 30.
I decided a couple of weeks ago that it would a far greater nightmare with all the images, so I've created paint code classes for all my images.
When I first turned on sizing classes / autolayout, Xcode asked if it should enable suggested layouts, this seemed to make sense. However it's made a real mess of the any / any layout.
Without adjusting the sizing classes setting any / any, I tried to install constraints for differing sizing classes. I want to make views bigger to fill the space, so I installed constraints with equal width (with aspect ratio) to subview with a multiplier so I would get proportional sized views. However this means I have about three sets of constraints per view. Which is a nightmare on my simple screen.
I then thought it might be better in my case to leave my iPad storyboard and have an iPhone storyboard. But my iPhone 6+ layout won't look very good. Turning on sizing classes made little sense with multiple storyboards.
I'm now thinking I could click the sizing class to regular / regular and compact / compact and have different views for each?
However any / any, which I can't get any sort of layout to look good, will still need views?
I'm also wondering if should let Xcode setup autolayout when I first enable it? As I say any / any looks bad.
I was thinking I could just plop my views in a vague position with any / any, apply suggested constraints, then click / flip to compact / compact and regular / regular and move things around.
I guess I'd also need to do that for compact / regular for 6+ too.
I'm just not sure what steps to take, I can't even think of workable plan b.
I've watched a million videos and feel I understand but I can't put it into practice.
HELP
My Suggest steps would be:
When we use autolayout and size classes, We always take start from wAny hAny
Take your simple Screen First Let say your login screen on ipad LandScape without autolayout will look like this:
Now you enable autolayout and size classes. Change Scene size to inferred (600, 600).
Now your view look terrible:
First Adjust it by just moving the views to center and correct places like this.
Now we are all set for applying autolayout constraints.
First give constraints to parentview(grey view). Unless parent view has correct constraints, childs view cannot be given correct constraints. So always make sure parent view have correct constraints.
Now we select the grey view and apply constriants like this:
Center vertically and horizontally in container.
Add width and Height Constraints. You got options. Give fixed width and height and modify it for different classes. like this:
Or you can add proportional constraints for width or height.(Better)
Now start with childs. Give them leading, trailing, top and height.
Height of label is 50 for wR hAny and 40 for wR hCompact
Final Results:
IPAD LANDSCAPE:
IPHONE LANDSCAPE:
Autolayout and size class are great and easy when someone get used to it.
HOPE IT HELP.
You have 2 options
1) Create separate layout for iPhone and iPad. In this options you might have to compromise targeted customization for iPhone6+. This option will consume less time, and if you have a time constraint or you think that you are not convenient working with autolayouts then go with this option.
2) Using any/any size class and add constraints to make you interface alright for iPad. After that only modify/add those constraints for iPhone specific size classes which needs to be adjusted. Once you have layout set with any/any for one of the device either iPhone or iPad, you will be surprised to know how much less constraints you will have to modify for specific size classes. This option requires good understanding of autolayouts or even if you are not convenient working with autolayout but willing to try and have no problem with time constraint then you should definitely go with this option.

Auto adjust label width to the text with auto layout xcode

I made a label in xcode and i want the label to adjust the text length using auto layout in xcode.
I searched the internet but nothing is working, It's like we can't reach the storyboard because nothing changes when we try something.
Does anyone know how to solve this.
Thanks in advance
In my experience problems with labels in storyboard usually have to do with not having your constraints set up properly in autolayout. I recommend looking through some tutorials (like this http://www.brianjcoleman.com/autolayout-xcode6/) about using autolayout.
Basically, you need to have your label set up so Xcode knows where to put it and how big it will be on all the different screen sizes of iOS devices. If you don't tell it how it should be constrained, Xcode will guess/decide for itself and often will cause the thing to disappear or shrink or something else you don't want.
Anyway goodluck.

Centering Objects From Storyboard

Im starting to experiment with storyboard. As you can see I have chosen the storyboard size to be height=regular and width=compact, which says “For all iPhones in portrait”.
The simulator I am using is iPhone6 however when I run everything is slightly off to the right.
Can someone explain what is happening or what I am missing?
The problem is that (as described in the comments) you are positioning the views without AutoLayout. When you just drag and drop the views, it's actually setting the frame's positions and sizes. The main problem with this approach is that it doesn't set the position and size in a proportional and related manner, taking in consideration the container. This is why you're getting the view at the current position. If you run in another simulator, maybe you can get the correct position, or maybe not. What you can do to change this is apply auto layout constraints to those views. There's a special constraint to center views horizontally. With autoLayout you can go further, specifying relation between one or more views, and those views not necessarily need have the same container view.
One quick example:
Notes:
I'm using universal storyboard to take those screenshots. It's more flexible and with AL you don't necessarily have to concern yourself with the size, as views adjust themselves depending on the constraints applied to.
EDIT:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
This is a link to auto layout guide provided by apple, a great tutorial on how to get your hands dirty in this little world.

Xcode Autolayout and Rotation

I want to ask if it is better to have autolayout turned off when I want my application's views to adjust themselves properly to match the device's screen orientation when the user rotates the iOS device from portrait to landscape and vice-versa.
It's because when I have autolayout off, I can adjust my view's autosizing and masks manually via the size inspector. The views seem to adjust fine to match the screen orientation.
I have already tried this with autolayout on and when I rotate the device, the views don't put themselves in place properly for some reason. This only happens for some apps though(I guess it depends on the original placement of the views in portrait mode)
Am I just missing something like a feature or setting for the autolayout that fixes this automatically? Or is it better to go with autolayout turned off?
Thanks
My recommendation is to use auto layout. It sounds from your question like you have not done much work with autolayout or the constraints that are generated for you. Yes, the generated constraints depend on the original placement of the view in portrait mode, but you will need to review and possibly change the constraints to make them work as you expect in landscape.
One of the key ideas driving auto layout is to specify how your views relate to each other so that iOS knows how to draw them in various circumstances, eg, rotating.
You mentioned that the views don't put themselves in place properly when rotated. It sounds to me like the generated constraints are not setting the spacing from a leading or to edge to the super view for something important.
WWDC videos cover autolayout concepts but beware that how and when you specify constraints has changed in XCode 5, so be sure to review the XCode videos from WWDC '13 for those changes.

Resources