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.
Asked
Active
Viewed 1,631 times
0

Rosh
- 169
- 16
-
I'm a little confused. What are you trying to accomplish? – Caleb Kleveter Nov 19 '15 at 17:15
-
also just change the storyboard mode to iphone 4 inch and see that everything is right? – Rajan Maheshwari Nov 19 '15 at 17:16
-
@Rajan Maheshwari I want to avoid checking for specific device and make it dynamic such that for any device I run it on should fit both, if necessary by automatically reducing the sizes of textfields. – Rosh Nov 19 '15 at 17:19
-
thats what I told. Just design your interface in inferred mode in storyboard and add constraints. They will be automatically adjusted with every device...dynamically – Rajan Maheshwari Nov 19 '15 at 17:19
-
Autolayout should be independent of the screen size; make sure that you pin the right side of the textfield and the leftside of the labels to the container. And put a horizontal constraint between each label-textfield pair. – koen Nov 19 '15 at 17:19
-
@Koen I have done exactly the same, I have thought about putting both textfield and label inside a uiview and add the constraint to the view instead of each labels and textfield and clip subview. But I was wondering if there is another robust way to do so. – Rosh Nov 19 '15 at 17:23
-
@RajanMaheshwari I have used auto layout and inferred. – Rosh Nov 19 '15 at 17:23
-
@Rosh: could you add a picture that shows all the constraints? Since you are using a `UITableView`, you can use the the `contentView` of each cell as you container. – koen Nov 19 '15 at 17:26
-
@Koen I just edited the question to show all the constraints I have applied. Thanks – Rosh Nov 19 '15 at 17:31
-
@CalebKleveter I want both labels and textfields visible in each row of the tableview, but on phone 5s it only shows textfields – Rosh Nov 19 '15 at 17:44
-
@Rosh, I don't see any horizontal constraints between the label and text and the enclosing view. See for instance the yellow/orange lines here: http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights – koen Nov 19 '15 at 18:40
-
I also don't see any constraints for 'L', I assume that is the label? – koen Nov 19 '15 at 18:48
-
@Koen Thanks Koen, I was not sure where the horizontal constraint should be for the textfield, but I have maneuvered it now. I have added a small view , which is set horizontally and vertically centered in the container and i have given the constraints based on that view, trailing for label to view and leading for textfield to view and the trailing 0 to container view. Seems to work fine but I wanted to do it without view. I wanted to see all the labels to be match the trailing for "confirm password" so that complexed the issue for the other labels. Thanks for your help. – Rosh Nov 19 '15 at 18:51
1 Answers
0
I used the view (with thickness 2) and centered it vertically and horizontally to use as a reference point.

Rosh
- 169
- 16