Where is the Xcode checkbox "Translates Autoresizing Mask Into Constraints" Where is the Xcode checkbox "Translates Autoresizing Mask Into Constraints" xcode xcode

Where is the Xcode checkbox "Translates Autoresizing Mask Into Constraints"


That checkbox is available in Interface Builder (IB), but only if you are developing Cocoa projects targeted for OS X. For iOS, it's not available at present. You can only set it programmatically.

Auto Layout on iOS from my understanding - and others feel free to pitch in here - is not a full implementation of what is available on OS X.

To be honest, given what you say afterwards, this checkbox is probably something you don't need to worry about. I think it is important in upgrading OS X projects to Auto Layout, but generally for iOS it's unlikely you'll be mixing one and the other. I.e., you either checkbox your Xib in the File Inspector to "Use Autolayout" or you don't.

enter image description here

That said, there is one use case where you may need to mess with that flag. That's if you want to create a standalone Xib file for a view, and then load that programmatically using loadNibNamed. When doing that, by default old style Auto Resizing constraints are converted into new style Auto Layout constraints. Typically I want to add my own so I set that flag to zap 'em.

myView.translatesAutoresizingMaskIntoConstraints = NO

Anyway that's another story.

Here's the link for more info, although you've no doubt had a look at it already:

Adopting Auto Layout

One thing I'd say is that if you're struggling with Auto Layout in the beginning - and you wouldn't be human if you weren't, we all have been - then I'd stick with Interface Builder and think about the golden rules. The most important one for me is that it hates ambiguity. It's like a vacuum in nature. Before you can delete the constraint that you don't want, you have to add the one that you do want then zap the old one.

The other mistake that I made was mixing Auto Layout and frames. So I'd do some code that checked the frame width then apply that to the constraints. Bad mistake. That really ends in tears. When you get into Auto Layout it's essential to really forget about doing anything with CGRect, frame, etc.

Stick with it though. Start with some simple views in IB and experiment. There is method to the madness, really.

One more link also worth looking at is:

10 Things You Need To Know About Cocoa Autolayout