Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storyboard: How do I let Xcode automatically update frames when I change layout constraints?

Tags:

I have seen a WWDC 2014 video (What's new in Interface Builder) where the presenter uses Storyboard and changes the height of a table view cell prototype within a table view controller (at around 7m30s). I see all the subviews of that cell resize as he drags the height-handle on the cell. This is great, because now you can see how your layout constraints behave in different scenarios very quickly.

He doesn't explain how he does it. Because when I drag the height-handle of a table view cell prototype, the frames of all my subviews don't update. They only update when I select from the menu: Editor > Resolve Auto Layout Issues > Update Frames (All Views in Table View Controller)

Is there an Xcode setting anywhere that toggles live-updating the view frames I see in Storyboard, obeying the layout constraints?

like image 529
Tom van Zummeren Avatar asked Sep 12 '14 18:09

Tom van Zummeren


People also ask

How do I enable auto layout in Xcode?

Create a new Xcode project. Select Single view app and name it AutoLayout. Leave the defaults unchecked: Use core data.

What are two properties that auto layout constraints control on a Uiview?

Auto Layout defines margins for each view. These margins describe the preferred spacing between the edge of the view and its subviews. You can access the view's margins using either the layoutMargins or layoutMarginsGuide property. The layoutMargins property lets you get and set the margins as a UIEdgeInsets structure.


2 Answers

In theory, you should be able to turn on “Descendants” in the “Resizing Behavior” popup menu (lower-right corner of the storyboard editor).

In practice, it's broken in your case. I have the same problem. You can report the bug at http://bugreport.apple.com/.

Possibly it works better in Yosemite. I'm still running Mavericks.

like image 60
rob mayoff Avatar answered Oct 05 '22 15:10

rob mayoff


Update: On XCode 8 Beta 5 I tested and found XIB where I needed to manually update Frame now automatically updates when I resize freeform view.

On XCode 7.3.1: This is not solution but I find a good compromise.

Go to XCode -> Preferences -> Key Bindings -> Search for "Update Frames". Remove existing shortcuts for the first item (which does not seem to work) and replace the shortcut to CTRL+OPTION+COMMAND+P for the second item. The shortcut is an example, you can add whatever shortcut you want that does not conflict with existing bindings).

Now each time you resize you can quickly use the shortcut to update the frame.

like image 35
Vlad Avatar answered Oct 05 '22 13:10

Vlad