Last active
August 29, 2015 14:05
-
-
Save pietrorea/089e308b4e9b46ded3ae to your computer and use it in GitHub Desktop.
Auto Layout ambiguous constraints debugging tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In UIViewController subclass | |
@interface UIWindow (AutoLayoutDebug) | |
+ (UIWindow *)keyWindow; | |
- (NSString *)_autolayoutTrace; | |
@end | |
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation | |
{ | |
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; | |
NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]); | |
} |
*<_UILayoutGuide:0x8e992f0> - AMBIGUOUS LAYOUT
^ Ignore if you see that on an iOS 7 simulator. It seems to be a bug with _autolayoutTrace.
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
From iOS 6 by Tutorials chapter by Matthijs Hollemans