iOS Universal App layout all messed up on iPhone? - ios

I am trying to make a universal app in Xcode 6 using swift, and it's not going so well. I have a tab bar controller app, and I am trying to make something like this:
(The height and width are set to Any) But when I run it on an iPhone 5 simulator:
How do I fix this? Will I have to make separate storyboards for each device?

I solved this issue by clicking on all of my items, then clicking on this guy near the bottom: Then clicking "Reset to suggested constraints".

What I understood is that, you should probably pin Top Space for the top most label and pin Vertical Spacing constraints for the other two buttons.
The "GO" button should have a vertical spacing constraint with respect to the "Control" label and the "STOP" should have a vertical spacing constraint with respect to the "GO" button or Bottom Spaceif you want to stick it to the bottom of the view.

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.

How to make same width for 5 button horizontally in xcode

I've designed those 5 button in my storyboard based on iPhone6. Now problem is my client told me to make their app can be workable in iPhone5 onwards. Current those 5 buttons in iPhone5 cannot be displayed proportionally as same width. That's why my question is please let me know how to make same width for 5 button horizontally in xcode?
Try this:
Add 5 UIButtons to yourViewController.
Highlight buttons
Click "Stack" icon at the bottom of the storyboard window.
On the UIStackView's attribute inspector, make sure it's "horizontal", distribution is set to "Fill Equally", and adjust the spacing to whatever you want.
Pin the UIStackView to left/right, top/bottom.
It should look something like this when you're done:
Using a stackView works great but for those whose target is below iOS 9, you can do it very simply with autolayout. Just select all 5 labels and use the "pin" icon on the bottom of the storyboard to check "equal width".
As already said in the comments you can create an Horizontal Stack View. Then add the 5 buttons to the Stack View.
Finally you can select the spacing by selecting the Stack View and, in the Attribute Inspector, increasing the Spacing field.

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.

Two Buttons. Above each other. Over whole screen

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.

iOS 7 AutoLayout sticky button to bottom screen

I have read lot of documents and tutorials about autolayout and constraints but I don't know what I'm doing wrong but in my case the examples doesn't work...I know that this is a repeated question but I don't know what I can do...
I'm trying to fix a button to my bottom screen. Bottom with 0 distance. In 4 hinches screen all is ok but when I'm changig to 3,5" the button dissapear. This is what I'm doing:
Normal button
Select button and add the bottom space constraint
Button look likes fine
When screen size changes, the button dissapears
Thanks a lot!
You can complete the following steps to achieve that:
Add bottom constraint, width and height:
Add horizontal centre constraint:
Now you can test on your storyboard by clicking the Apply from factor button:
Select the button, and select "Update Frames"
Suggestion: you should add constraints to the button for left, right and height.

Resources