Whenever I write for iOS, I always struggle with Autolayout. Does anyone else have these problems? How do you overcome it? Have you reverted to alternatives like SnapKit?
This is what I'm trying to accomplish:
UITableViewCell
+-------------------------------------+
| +-------------------------+ +-----+ |
| | Label #1 | | #2 | |
| +-------------------------+ +-----+ |
+-------------------------------------+
I want the following:
- Label #1 to be vertically centered
- Label #2 to be vertically centered
- The leading space from the left bounds to Label #1 to be constant
- The trailing space from Label #2 to the right bounds to be constant
- The horizontal spacing between Label #1 and Label #2 to be constant
These are the warnings I'm getting: Ambiguous Layout Group
- Main.storyboard: warning: Ambiguous Layout: Vertical position is ambiguous for "Label #2". (1)
- Main.storyboard 2 views are horizontally ambiguous.
- Main.storyboard Width is ambiguous for "Label #1". (2)
- Main.storyboard Width and horizontal position are ambiguous for "Label #2". (2) Main.storyboard: warning: Ambiguous Layout: Vertical position is ambiguous for "Label #1". (1)
My thoughts:
- Vertical position should not be ambiguous. If I don't set it to be vertically centered, it appears wrong on my device.
- No width constraint has been set by me. I don't even see any width constraints in IB to remove.