Categories
Blog iOS development

How to turn off iOS autolayout for iOS5 compatibility.

Got caught by one of the gotchas in keeping things compatible between iOS6 and iOS5 devices.

While both iOS5 and iOS6 support UI Storyboarding (you have to forego this feature if you want your app to run on iOS 4.0 as well),  iOS 5 does not support the new auto layout feature in iOS 6.   Autolayout (which I hope to talk more about soon) has some very powerful features for making sure your screen layout works in different orientations, on the taller iPhone 6 screen, etc.

If you try running a program with autolayout enabled, iOS 5 will crash your app, as the OS doesn’t recognize the UIConstraint selectors needed to draw the screen.  This is also a backward compatibility issue on Mac OS X — Lion uses autolayout, but Snow Leopard doesn’t.

Turns out, however, that when you create a new project in Xcode 4.3 and up,  autolayout is enabled by default.  However, there is a setting that lets you turn that off.

This site has a good tutorial of what to do, complete with screenshots.

This is one of the issues iOS (and Android, for that matter) developers constantly have to think about — which new features do I use, and which do I have to forgo in order to support older devices?   In my case, I will be running this program eventually on an iPad, and my 1st gen iPad is stuck at 5.1, so no autolayout on this project.