4

I've been working on an enterprise iPad client app which has a fairly complex containment view controller hierarchy. I recently had to implement a redesign in the app starting view, the server login view. I decided to take the opportunity to implement the redesign using auto layout and leave the rest of the app unchanged. After a couple of days of watching the WWDC videos and hacking at the code, I had smooth, animated repositioning of the login textfields for rotation and keyboard show/hide events. Satisfied with the results, I git merged the refactor branch, only to find the app crashes when using the app after the logging in, with no debugger hints. I finally figured out that auto layout had somehow cascaded to child container view controllers.

In the Main.storyboard there is a "main" navigation controller which has a RootViewController root view controller whose view is a container for child view controller views, beginning with the login view, then swapped to whichever view controller was last used by the user. After the refactor, in IB, the server login controller has "Use Autolayout" checked. But all of a sudden one of the child view controllers, which never had autolayout enabled, is also checked. When I uncheck it on that view controller, suddenly my server login vew controller autolayout checkbox is unchecked. Does this mean that auto layout is enabled/disabled on ALL the view controllers in the storyboard?? If not, does anyone know what's going on? Xcode 4.6

seeker12
  • 731
  • 2
  • 8
  • 20

1 Answers1

3

The answer came from KMT in the Apple developer forums that auto layout is enabled at the Storyboard level. I somehow missed this critical bit in the WWDC vids.

I solved my particular issue by creating a new storyboard file with "Use Autolayout" enabled and moved my autolayout-enabled view controllers into it. Unfortunately, in the process of discovering that Autolayout is enabled at the storyboard level meant that whenever I unchecked the "Use Autolayout" checkbox on any object in Main.storyboard, IB applied best-guess constraints to replace the existing springs/struts attributes I had previously set up. And then when unchecking "Use Autolayout" checkbox, it applied best-guess springs/struts attributes to replace its best-guess constraints. The net result was that I had to reapply the springs/struts settings to many of the views in the storyboard file.

seeker12
  • 731
  • 2
  • 8
  • 20