xcode 如何在 Xcode7 的自动布局中更轻松地“更新所有帧”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32656052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to more easily "update all frames" in autolayout in Xcode7?
提问by Fattie
The "Update Frames" calls are often grayed-out in Xcode
“更新帧”调用在 Xcode 中通常是灰色的
the only way I know to have it update frames to match your constraints, is, tediously select your highest-level view and than (sometimes) you can fish in the menu bar for "Selected Views"->"Update Frames". Further, "All Views"->"Update Frames" would appear to often simply not work or work in a way I can't understand.
我知道让它更新框架以匹配您的约束的唯一方法是,繁琐地选择您的最高级别视图,然后(有时)您可以在“选定视图”->“更新框架”的菜单栏中钓鱼。此外,“所有视图”->“更新框架”似乎通常根本不起作用或以我无法理解的方式工作。
Surely there's just a keystrokeor button which updates all framesstraight away to match any newly-entered constraints (such as those made using control-drag).
当然,只有一个击键或按钮可以立即更新所有帧以匹配任何新输入的约束(例如使用控制拖动所做的约束)。
Note .. for 2016 you can use this very handy button, which at least brings up the same sub-menu as you can find by searching in the menu bar menu.
注意 .. 对于 2016 年,您可以使用这个非常方便的按钮,它至少会显示与您通过在菜单栏菜单中搜索可以找到的相同的子菜单。
However it would seem (see my comments w/ ZaBlanc below) that there is perhaps actually an Xcode bug, and you CAN NOT assign a keystroke to the "All Views" items. (The ones you usually use.)
然而,看起来(见下面我对 ZaBlanc 的评论)可能实际上存在一个 Xcode 错误,并且您不能为“所有视图”项目分配按键。(您通常使用的那些。)
Even worse .. in Xcode 8 ...
更糟糕的是......在Xcode 8中......
they seem to have removed the 'update frames' option... WTH
他们似乎已经删除了“更新框架”选项...... WTH
采纳答案by Sega-Zero
AFAIK, there is no keystroke for update all frames, but here's a key tip:
AFAIK,更新所有帧没有击键,但这里有一个关键提示:
- If you have a misplaced views, press the yellow arrow in the document outline (the views tree to the left of canvas), press yellow triangle on any view in the list, then select update frames and check
Apply to all views in container
- this will update all misplaced views in the selected view controller
- 如果您有错位的视图,请按文档大纲中的黄色箭头(画布左侧的视图树),在列表中的任何视图上按黄色三角形,然后选择更新框架并选中
Apply to all views in container
- 这将更新所有错位的视图选定的视图控制器
Additionally, you probably already know:
此外,您可能已经知道:
You can add a new constraint with
Add New Constraints
button in canvas bottom right and select "Update frames" option.You can select any view by mouse-click and holding Option+Shiftkeys - this will show you the list of all the views, that intersects with mouse pointer. After that you can select update frames menu item on a selected misplaced view.
您可以使用
Add New Constraints
画布右下角的按钮添加新约束,然后选择“更新帧”选项。您可以通过单击鼠标并按住Option+Shift键来选择任何视图- 这将显示与鼠标指针相交的所有视图的列表。之后,您可以在选定的错位视图上选择更新框架菜单项。
回答by ZaBlanc
It's easy. Go to Preferences -> Key Bindings. Type "Update Frames" on the top. You'll see two appear. You'll want the bottom one (it will be the one without a keyboard shortcut assigned.)
这很简单。转到首选项 -> 键绑定。在顶部键入“更新框架”。你会看到两个出现。您将需要底部的一个(它将是没有分配键盘快捷键的那个。)
Assign it to ?= or anything else you like.
将它分配给 ?= 或任何你喜欢的东西。
Life changed.
生活变了。
- Just for anyone reading, with Xcode 8.3. The popup menu command no longer exists. The menu barcommand Editor -> Update Frames does work. However there's a bug, the default key binding on that does not work. If you add a custom key combo, that custom key combo does work.
- 仅适用于使用Xcode 8.3阅读的任何人。弹出菜单命令不再存在。在菜单栏命令编辑器- >更新框架做的工作。但是有一个错误,默认的键绑定不起作用。如果您添加自定义键组合,则该自定义键组合确实有效。
回答by Ducky
The same as you, I thought that it's very annoying to fix the misplaced views manually by selecting them and choose that boring option from Xcode menu. After trying hard to shorten the time to fix the layout issues, I had to admit that there is no way to call the function "Update Frames" from command line. So I ended up doing this way:
和你一样,我认为通过选择它们并从 Xcode 菜单中选择那个无聊的选项来手动修复错位的视图是非常烦人的。在努力缩短修复布局问题的时间后,我不得不承认无法从命令行调用“更新框架”函数。所以我最终这样做了:
- Open Xcode warnings & error inspector window
- Filter all layout warnings by using the keyword "frame for"
- Click on warnings to quickly locate to the misplaced views then press
Command + Option + =
- 打开 Xcode 警告和错误检查器窗口
- 使用关键字“frame for”过滤所有布局警告
- 单击警告以快速定位到错位的视图,然后按
Command + Option + =
That's the fastest way I know. Please try it out!
这是我所知道的最快的方法。请尝试一下!
You could also find more details HERE
您还可以在此处找到更多详细信息