如何默认禁用 xcode 4.5 的自动布局?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12716891/
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 disable auto layout by default for xcode 4.5?
提问by Mike
A question here: Xcode 4.5 corrupting XIBs?illustrates the problem and solution for xcode 4.5 creating nib files that can not run on ios5.
这里有一个问题:Xcode 4.5 会破坏 XIBs?说明 xcode 4.5 创建无法在 ios5 上运行的 nib 文件的问题和解决方案。
Does anyone have a solution to prevent the auto layout checkbox from being defaulted to on? I'm worried that in the process of development, I will forget to unchecked that box.
有没有人有解决方案来防止自动布局复选框被默认为打开?我担心在开发过程中,我会忘记取消选中那个框。


回答by Simon Germain
There's a way, but it's kinda convoluted and, I might add, not recommended.
有一种方法,但它有点复杂,我可能会补充说,不推荐。
You can open your template files located in:
您可以打开位于以下位置的模板文件:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/User Interface/, in each directory, there are .xib files. They are XML files, open them with a text editor.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/User Interface/, 在每个目录中,都有 .xib 文件。它们是 XML 文件,使用文本编辑器打开它们。
Replace the following line:
替换以下行:
<bool key="IBDocument.UseAutolayout">YES</bool>
to
到
<bool key="IBDocument.UseAutolayout">NO</bool>
I will repeat though, this is not recommended.
我会再说一遍,这不是推荐的。
回答by Tibor B?decs
There is a project templates folder, you should modify the xib files there too.
有一个项目模板文件夹,您也应该修改那里的 xib 文件。
Also if you want to disable auto layout in storyboards, you should change this attribute:
此外,如果您想在故事板中禁用自动布局,您应该更改此属性:
useAutolayout="YES"
in each storyboard file to NO.
在每个故事板文件中为 NO。

