凡设置X code ++ 4.5 translatesAutoresizingMaskIntoConstraints [英] Where to set translatesAutoresizingMaskIntoConstraints in Xcode 4.5

查看:132
本文介绍了凡设置X code ++ 4.5 translatesAutoresizingMaskIntoConstraints的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置 translatesAutoresizingMaskIntoConstraints NO 。默认情况下它设置为(协助与大多数被从过渡支柱和弹簧新的自动布局应用程序)。

I need to set translatesAutoresizingMaskIntoConstraints to NO. By default it is set to YES (to assist with the majority of apps that are transitioning from struts and springs to the new Auto Layout).

有没有什么地方在X code其中默认可以从改为YES NO

Is there somewhere in Xcode where the default can be changed from YES to NO?

还是我不得不手动设置它为每一个看法?

Or do I have to manually set it for every view?

推荐答案

这是一个很大的问题 - 和一个我一直试图找到一个答案自己。可悲的是,它看起来像没有速战速决。目前,苹果认为,基于约束的布局选择加入 - 即使命名的<一节href=\"http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html\"><$c$c>UIView类参考:

This is a great question - and one I've tried to find an answer to myself. Sadly, it looks like there is no "quick fix". Currently, Apple considers Constraint-based layout Opt-in - even naming a section of the UIView Class Reference:

在选择加入基于约束的布局

Opting in to Constraint-Based Layout

但是,选择加入是不是全球性的。我presume这是因为不是一切看起来都好,如果你只是把弹簧与放大器; Struts的进入限制。一些UI元素打破,或者你会得到一吨的不可满足的约束错误。

But that Opt-in is not global. I presume this is because not everything looks good if you just turn Springs & Struts into Constraints. Some UI elements break, or you would get a ton of unsatisfiable constraints errors.

我能想到的一个的可能的解决方案 - 我还没有尝试过自己,但你可以做的的UIView 一个类别,设置<强>所有 的UIView 对象返回 NO > - (BOOL)translatesAutoresizingMaskIntoConstraints 。虽然我不知道这是什么会打破,将全局设置 translatesAutoresizingMaskIntoConstraints NO

I can think of one possible solution - I have not tried it myself, but you could make a category on UIView that sets all UIView objects to return NO for - (BOOL)translatesAutoresizingMaskIntoConstraints. While I do not know what this would break, it would globally set translatesAutoresizingMaskIntoConstraints to NO.

下面是<一个href=\"http://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html\">a很好的介绍分类,如果你想了解更多关于他们的!

这篇关于凡设置X code ++ 4.5 translatesAutoresizingMaskIntoConstraints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆