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

余生颓废 提交于 2019-12-22 01:38:07

问题


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?


回答1:


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.




回答2:


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.




回答3:


The correct answer is marked that it is a bug, but it might be the case that Interface Builder cannot make sense of your constraints to auto update them. I'm using Xcode 6.2 on Yosemite. I thought I had the same issue, but as my constraints have become more complete, Interface Builder is updating them as I go.



来源:https://stackoverflow.com/questions/25814840/storyboard-how-do-i-let-xcode-automatically-update-frames-when-i-change-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!