Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use autolayout constraints in a tableview

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?

All the fields in this form are inactive

like image 947
ZviBar Avatar asked Jan 17 '14 09:01

ZviBar


People also ask

How do I create a constraint in Autolayout?

To create constraints select the button and click the Align icon in the auto layout menu. A popover menu will appear, check both “Horizontal in container” and “Vertically in container” options to center the button on the screen. Then click the “Add 2 Constraints” button. Run the application.

How do you add constraints to a storyboard?

Select the view you would like to constrain. Then tap the button to the right of the one you have selected and use that menu to define your autolayout constraints. If you want it to work for all devices make sure your storyboard is on the wAny hAny size class setting.

What is Autolayout in Swift?

Auto Layout constraints allow us to create views that dynamically adjust to different size classes and positions. The constraints will make sure that your views adjust to any size changes without having to manually update frames or positions.


1 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

like image 114
Sergey Demchenko Avatar answered Oct 04 '22 22:10

Sergey Demchenko