Skip to content

Instantly share code, notes, and snippets.

@pietrorea
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pietrorea/089e308b4e9b46ded3ae to your computer and use it in GitHub Desktop.
Save pietrorea/089e308b4e9b46ded3ae to your computer and use it in GitHub Desktop.
Auto Layout ambiguous constraints debugging tool
//In UIViewController subclass
@interface UIWindow (AutoLayoutDebug)
+ (UIWindow *)keyWindow;
- (NSString *)_autolayoutTrace;
@end
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
}
@pietrorea
Copy link
Author

From iOS 6 by Tutorials chapter by Matthijs Hollemans

@pietrorea
Copy link
Author

*<_UILayoutGuide:0x8e992f0> - AMBIGUOUS LAYOUT

^ Ignore if you see that on an iOS 7 simulator. It seems to be a bug with _autolayoutTrace.

@pietrorea
Copy link
Author

Also, don't submit to the app store with _autolayoutTrace. Wrap around a preprocessor macro (e.g.g #ifdef DEBUG) so that it doesn't make it to the final binary. Otherwise the app may be rejected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment