I have this table view and am unable to add any autolayout constraints. The control drag doesn't work - no constraints show up, and the builder form seems inactive, I can't set any values in there (see below). Autolayout is enabled everywhere across the project, basically on every view. Why is that?
-
Are you sure you have TableView selected ? not cell or something else ? The screen doesn't show the whole screen unfortunatelly to confirm – Grzegorz Krukowski Jan 17 '14 at 09:39
-
Nope, the textfield in the upper part of the tableview is selected. I would like to add constraints on that relative to the tableview. – ZviBar Jan 17 '14 at 09:43
4 Answers
It is because you selected cell or Content View in cell. You can add constrains only to views inside Content View.
UPDATE
Also you may not be able to add constraints to view if this view is top level object (is not a child of parent view).
UPDATE 2
You can add auto layout constraints only to UIViews and their subclasses. In your case you try to add constrains to UITextField which is located inside UINavigationItem (it is not subclass of UIView).
Here you can find the similar issue and answer on it: iOS Autolayout and UIToolbar/UIBarButtonItems

- 1
- 1

- 2,924
- 1
- 24
- 26
-
I selected the textfield in the upper part of the screen. I would like to add constraints on it so that when the screen is rotated to the horizontal position, it basically is longer. – ZviBar Jan 17 '14 at 09:48
-
@ZviBar can you please attach simple storyboard or xib file where this issue is reproduced? – Sergey Demchenko Jan 17 '14 at 09:50
-
I recreated the scenario in a small project here (http://www.sendspace.com/file/cnnw5e). The textfield is inside a navigation item. – ZviBar Jan 17 '14 at 10:03
-
-
Thanks for taking time to help me. I appreciate it, although I'm unable to achieve my disired result from the thread on the similar issue. – ZviBar Jan 17 '14 at 13:46
Make sure the Cell Style is "Custom" and Add New Constraints should be enabled.
I had a Cell with Style 'Basic' any I was able to customise the label and add a UITableViewCell subclass. I had accidentally linked my outlet to the UILabel in the default BASIC style cell.

- 5,277
- 2
- 41
- 62
This is an edge case but it happened to me so it can happen to someone else.
While dragging the view into the cell, I accidentally dropped it at the UITableView
level instead and it was added as a header of the UITableView
.
I then dragged it from the header of the table to the cell where I initially meant to drop it. Since it was initially added to the UITableView
as a header, where constraints for that view directly wouldn't make sense, Interface Builder wouldn't show me the option to change the layout type from autoresizing mask to constraints.
When I remembered that I had initially dropped it in the wrong place, I just deleted the view and re-added it, this time dropping it on the right spot the first time and constraints were available.

- 2,042
- 20
- 23