Maintaining consistent spacing with autoresizing masks for three text fields - ios

On my iPad storyboard, I have 3 text fields with a consistent spacing in portrait mode. I assigned autoresizing masks as shown in the image below, but after rotation to landscape, there is a gap between the second and third text fields.
If I want to maintain the left and right margins after rotation (currently on the first and third text field masks), is there a way to specify that these three text fields should be resized in the same manner?
The storyboard does not currently have auto layout or size classes enabled.

Related

UILabel scales only for certain text lengths

I have a custom UIView containing a UILabel and a UISwitch. The switch and the label are constrained to be next to each other with their center-y equal and their sides matching the sides of the parent (with a margin). The label is constrained to connect with the top and bottom of its parent (again, plus margin) with its number of lines set to 0 so it can scale as large as it needs to be to fit all the text, using word wrapping as the line break mode. I have a bunch of these custom views below each other in a vertical UIStackView with alignment and distribution set to fill. The stack view itself is positioned inside a scroll view which is constrained to all sides of the root view (which scrolls as expected). Here's a screenshot of the situation that also shows my problem:
I've added a red background to the label in the custom view to show its boundaries. Separator views are added between the custom views. The problem becomes apparent in the second custom view in this screenshot. Its label text is actually WordOne WordTwo WordThree WordFour, but for whatever reason the text is wrapped without the label / parent increasing their size to contain it. Adding an extra word, as in the view below it, suddenly does scale the label to show all of its lines. I've set compression resistance to UILayoutPriorityRequired for both the label and the parent, to no avail. I have a workaround involving a layoutSubviews override with a manual calculation of the label size, but I'd prefer both understanding what's going on and of course avoiding having to use a hack. Can anybody shed some light on this behavior?

iOS fixed size views displaying different widths and heights

So I have some one line views that are set to be dividers between fields. They are UIViews that I just set the background color on. All of them are in IB with constraints, the width or height set to 1, and then tied to other fields and/or the leading/trialing space to the superview.
The view size for he VC is inferred, and is at the 4 inch size.
But when viewed on a 6 device, or in the simulator, these single point views sometimes come out as what appears to be 2 points. I've tried raising the compression resistance of the views, as well as tying them to items that don't require them to expand if it's needed to display the view while keeping to the constraints.
The top, middle and bottom lines, as well as the two vertical ones are all 1 point width or height views.
What is causing these views to display like this?

iOS Storyboard: Different Layouts for Different Devices

As you can see, this is the different device previews for my current storyboard. The transparent green on the bottom is taken up by another view controller, but the spacing needs to be fixed for each different size class. I tried setting the width and height in the storyboard to the setting I want to change, but it changes that attribute for all the size classes. How can I just change, for example, the size of the Label at the top for ONLY 3.5in iPhones or the green layout for ONLY 5.5in iPhones?
Choose the pin of the label and go to Attributes Inspector of the Utility Area. You can find + button left to the constant text field.
When you tap the button, you can choose the size class you need.

Auto layout for textfield and label in iOS

I am trying to create a static tableview for sign up form. I have label and textfields. I want to apply auto layout such that label and textfields are visible but I am not able to achieve that for iPhone but it seems to work for iPad, since, I guess iPad are bigger. I have applied height and aspect ratio constraint to textfield. I have pinned labels to the left edge of the textfield.
I used the view (with thickness 2) and centered it vertically and horizontally to use as a reference point.

Change Text Alignment in UITableViewCell On Rotate

I am using sizing classes to turn two xib files (iPhone vs iPad) into one. Most orientations have a 2x2 grid of UILabels above a UITextView. However, for iPhone portrait, I want the UILabels to stack vertically. I have this working great with sizing classes. I was disappointed to see, however, that sizing classes don't allow for the change of text alignment. Refer to my diagrams below. In the main orientation I have the text in the yellow and blue UILabels right-aligned. In the iPhone portrait orientation I want the same UILabels to have left-aligned text. How can I change this if the user rotates the device while viewing these table cells? I figure there's a better way of doing this than reloading the table.
I dont think it is possible to setup the text alignment based on the screen orientation or device. however you can create 2 labels, one with left aligned text and the other with whatever you're using otherwise, in a way that they are exclusive to the screen layout you're using. I.e. one label for iPhone and one label for everything else.
You can select then, for that UILabel object in storyboard, which screen layouts it will be installed for.

Resources