Autolayout for button to bottom - ios

I try to adapt my app for the 3.5 inches iPhone, but currently I have a problem, because I don't really get how to use the constraints to get what I want.
This is what I have for 4 inches:
This is what happens, if I apply 3.5 inches Form Factor:
But this is what I would like to have, managed by constraints:
Thank you very much in advance.
Regards.

I Think you need add constraint on all three objects
Do following steps
1). First add three constraint to top image view
I am attaching the image for that
In this image you need to give value according to your requirement
as i understand from above image i am giving the 20 from top and 0 from left and 0 from right
then click on the Add constraint button as you see in bottom of the image
2). then add constraint on take a note button in the same way that you have added from first
3). add constraint on last button

Add this constraint to your button.

You need to apply autolayout constraints on both note and save button along with imageView so when u open your app in 3.5 or 4 inches it will adjust and fit your component as per your size. You could also go for RESET TO SUGGESTED CONSTRAINTS if you are not able to understand on how to apply and for more on autolayout you could check out this tut

Related

How to set Constraints in Xcode Using StoryBoard?

I am trying to set constraints in iphone devices using storyboard in xcode. But i am getting some issue.I have placed two textfields and two buttons using drag and drop.Everything is going fine except one button whose width get reduced in iphone 5s and i don't know the reason behind this.Can anybody help?
png
Some practical solutions:
add a "width" constraint for that button ( it can be >= also )
adde "equal widths" constraint for that button and another element
adde "trailing and leading" constraint for that button
also
try with different size classes to see your result.
It would also help your question to add more info on how your constraints are setup.
Vandana, if the button width is reduced, it simply means that it does not have a fix width. You have 2 options
1) Set a width constraint on the button (e.g. I want it to be 300 points long)
2) Set a leading and trailing constraint (e.g. on the left I want a fix 10 points distance from the bezel, and on the right I want a fix 10 points distance from the bezel.
I believe there's a warning in the storyboard, you just need to select the best option for you:
Ways to add a width constraint:
1) Option + click and hold "the button"
2) drag to the left or right on storyboard and release while it's on the button:

Need constraints for y position, height - Auto layout Storyboard

First let me tell that I have gone through multiple same kind of questions available in Stack Overflow but neither of them helped me.
So I created new question for discussing my problem.
I am beginner with iOS programming and with layout making in Storyboard so daily facing few problem in designing. With this problem, I already spent my 2 days but may be its really easy for an expert person to help me in this problem.
I was getting red warning in layout for need constraints for y position, height and any how I want to resolve this.
Following image will make you more clear regarding this:
Specifically I was getting problem in video view and button below that regarding y position constraints.
So please suggest me, how to solve this problem?
I was getting same problem multiple times when I was making layout so if I learn this solution then it will be big relief for me.
You need to set the VideoView Height constraint.
Steps:
Select the VideoView.
Click in "Add New Constraints" next to "Align" and after "Resolve Auto Layout Issues" option.
Set the height constant you want.
Check the height box.
You also need set the Y position, because the VideoView don't know what is below and above. So, click the top constraint to make it look red, set the space that you need between your topView and the VideoView (in this case of my image example: 0)evidency of top constraint
Click "Add 1 constraint"
You can give the constraints in the different ways as per your requirement:
1) Select your video view
2) Add new constraint and add the top constraint (Constraint between your Video view and top view, in your case the view with text surfa)
3) Select bottom constraint (if bottom buttons hight is fixed)
or
3) Select the height constraint (if you want to fix your video view height)
or
3) You can give the aspect ratio to video view (In this situation your view's height will be change as per the screen size)
Hope this will be helpful to you.

Split View into four Subviews with 25% width

I want to insert 4 Subviews with exact 25% percent width of the SuperView.
So, my question is how to achieve that with XCode's Autolayout? In Android I would use a GridLayout or a LinearLayout...
Thanks in advance
Just set your constraints like this image,you will get what you want
And this is preview in different screen sizes
You have to select all the four views, and add top, bottom, left, right constraints to zero and equal width constraint.
Your constraints should look like this.
In the screenshot, the four views are arranged over a container view. If you dont't want the container view, then you have to specify the height constraint also.
You should use UIStackView that is introduce in ios9 and xcode 7.0
Here is a link of the tutorial have a look its like a linear layout in android
http://code.tutsplus.com/tutorials/ios-9-getting-started-with-uistackview--cms-24193
There are alot other ways as this is the new one and it help to reduce work and time both so you should use it.Thanks

3.5inch screen cannot accommodate all subviews

I have 3 labels .First one at the top of the screen, second in the middle and third below. I used both( size class(cW rH)+ autolayout)to layout the labels.The third label appears in all sizes expect the 3.5inch screen. Can autolayout and/or size class help me accommodate my third label in some way?.I know putting a scroll view or doing programatically will help me achieve what i want but just want to know whether the current iOS SDK is intelligent enough to cut this.
You have to use different constraint for each label.
Please check below screenshot to understand how to set constraint to each label.
May be it will help you to set labels.
I have Submit label as third label and I did following for it . Try using it and dont forget to click add constraint after doing it

Button At Center of iPhone 3.5 and iPhone 4 inch using AutoLayout?

I have simply Drag and button and set Image on it as following
Yet I have not used any CONSTRAINTS. As I run on iPhone 3.5 inch, it shows like below, where Button goes slightly down towards Y-Axis.
I have TWO Questions here to ask.
1. Which Constraints should I add to this Button?
2. Why these constraints are added, Simply I want to know Formula for calculating it.
I would be thankful, If someone comprehensively describe my questions.
Thanks
Question 1:
This should be pretty easy in IB, using the Alignment Constraints dialog. Click the button, and in the Alignment Constraints, check Horizontal Center in Container and Vertical Center in Container. In the below collage, you can see how this centers the button on both 3.5 and 4 inch displays.
(Don't forget to click the button "Add 2 constraints" :-) )
Question 2:
Not sure what you are after... Formula?
select button
click resolve autolayout issues (bottom right)
add missing constraints
Question 1 & 2:
It is depends on your requirement and layout design.
adding constraints for alignment or spacing, you can also use this menu to resolve layout issues, and determine constraint resizing behavior.
Align. Create alignment constraints, such as centering a view in its
container, or aligning the left edges of two views.
Pin. Create spacing constraints, such as defining the height of a
view, or specifying its horizontal distance from another view.
Issues. Resolve layout issues by adding or resetting constraints
based on suggestions (see “Resolving Auto Layout Issues”).
Resizing. Specify how resizing affects constraints .
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/WorkingwithConstraints/WorkingwithConstraints.html#//apple_ref/doc/uid/TP40010853-CH8-SW1

Resources