Two Buttons. Above each other. Over whole screen - ios

I just like two buttons above each other with no margins. This seems like an easy task, but I am new to iOS and I wasted too much time now. I tried dozens of contraints but it never went out well. I always ended up with setting the leading Spaces to -24 and having marings above and beneath the buttons. I am using xcode6, iOS8.1 and storyboard. My app is landscape only. Can someone please teach me what to do?
The buttons should look like seen in this picture: Fullscreen, no margins and Button1 should reach unter the statusbar!

I'll outline the steps:
Pin Button 1 to 0 spacing on Left, Right, Top
Pin Button 2 to 0 spacing on Left, Right, Bottom
Select both buttons, then Pin heights equally
(You can access pin either from the Editor tool bar in the top menu, or from the second icon in the constraints area)
The thing with constraints and auto layout is that you only need enough constraints to let the app calculate where elements should be at all times. You might be able to get away with less constraints.
To get remove the borders, you need to change the button Type in IB from System to Custom, then you can drag and alter the margins to remove them. Following that you will need to update constraints on the buttons.

Related

How to center TextField using Xcode constraints?

I am new to iOS and am trying to align these TextFields in iOS. Below is how I would like it to look on an iPhone 7.
However, on the iPhone 7 Plus, the TextField shifts to the left of the center, despite my constraints.
Why is this? I have a constraint that aligns them to the Center, as seen on the right part of the screenshot.
It is very simple!! Just follow below steps,
Open you .xib or .storyboard file
Select view you have to add constraint
Click on align button at the right - bottom corner
Set horizontally in container constraint 0
Then press add constraints button
You can add any constraints to any view by following these steps
You just have to seth trailing and leading space fixed means both left
and right indicators should be red as shown in the screenshot.
For more details see the screenshots:
It will remain fixed from left and right in all the screens.
in your case is important set the width constraint.
However you can use trailing and leading constraints, in this way you will not need to set a defined width for your textfield and the position is correct for all type of devices.
If you want design like this so you have to take UITableview then take UITextfield for every cell beacuse you use every cell as view so easily manage all textfield and constraint. And also easily scrolling if device is display small.

Buttons look different on storyboard to view

Why is my the elements of my storyboard (buttons) showing up differently in the simulator to the device? I've got auto-layout on, and I've disabled size-classes but surely this shouldn't matter?
How it looks in the storyboard: http://s11.postimg.org/h1xbn5f9v/Screen_Shot_2016_02_09_at_18_57_54.png
It looks fine on the iPhone 5 (it matches the storyboard), although on the iPhone 6 and other devices it's different.
How it looks on the iPhone 6:
http://s17.postimg.org/tfdaagt3y/Screen_Shot_2016_02_09_at_18_58_39.jpg
I'm using a view to hold together the buttons and centered it horizontally.
Any ideas? I'm baffled. It seems I'll have to programmatically place it if this is the case...
From the images you've shared thus far, I don't see any constraints other than the height/width. You need to select the buttons of interest and then hold Control and drag to the bottom of the container, click "Vertical Spacing to Bottom Layout Guide" and then on the right panel, set Vertical Space Constant to adjust (incase you find yourself having to temporarily place the button in the container to get the "Vertical Spacing to Bottom Layout Guide" option when Control + Dragging). Looks like you'll need a negative number for the Vertical Spacing constant to achieve the buttons being slightly out the bottom of the container. Then "Update Frames for Selected View" by pressing Control + Option + =
You can also try clicking the little triangle icon and clicking "Add Missing Constraints." This will add missing constraints needed to keep your icons where they are in the Storyboard, but sometimes I've found that using this automatic feature doesn't achieve my exact intent.

16 pixels margin left and right on UIView created with autolayout

I use autolayouts not for a long time and they often confuse me.
I have a wired constraints behaviour. I want to create a red view and make its margins 1/1/1/1. I tap a corresponded icon in the storyboard and set all fourth constraints to 1.
First of all values for left and right constraints are -16 and it's very strange. I have no idea where Xcode takes them.
I set all constraints to 1 and run my application. On the screen I see the view with top and bottom margins equal to 1 and right and left equal to 15.
And I have this behaviour always in every project. It very confuses me and don't give make UI correctly.
Does anybody know how can I avoid it? Everything I need it's say "Hey, Xcode, set margins for this view to 1/1/1/1" and the visible result will be the view with margins 1/1/1/1.
As usual, just after posing a question I've found a solution. When you set constrains turn the "Constrain to margins" checkbox off.

storyboard IB to big for simulator [duplicate]

Here is design of my storyboard:
And here is output:
Why this button is not located in its correct location?
This is a common question on Stack Overflow. You need to add auto layout constraints to the button. It doesn't know if you mean "in the centre" or "300 points from the left". You can add them by selecting the button and tapping the button with the square on it in the bottom right of the editor.
These are the buttons.
The buttons are...
Align views. Either multiple views or along a single view with its superview.
Add constraints to a specific view. Left, Top, Height, Width, etc...
Auto constraints. Update frames to constraints. Etc...
Resizing options.
You need to add constraints to ALL of the views in your app.
So, on button2 you will need to tell it...
How far down from the top.
Align the button to the centre of the superview.
For button1 you will need...
How for down from the top.
How far in from the left.
For the map...
Zero from the bottom, left, and right. (That's three separate constraints)
How much spacing between button1 and the top of the map.

Set fixed space between 2 views in Interface Builder

I am trying to learn to use layout constraints in interface builder but I am running across an issue...
I've got two views, one UILabel and one UIImageView, and I'd like a layout as follows:
the label should be centered in the superview
the imageview should be a set distance to the left of the label
Seems pretty simple, but I can't figure out how to impose a constraint for the second condition (the first is done automatically). Anyone know how to do this?
Thanks!
Click on both views while holding the command key so they're both highlighted. Then click on the pin button in the bottom right hand corner of IB (the middle button). Select horizontal spacing and the constraint should now be added. You should be able to adjust it as needed from there.

Resources