I just created an empty iOS Project for a 'Single View Application' which targets iOS7, but when i ran the empty project and inspected my viewtree by typing:
po [[UIWindow keyWindow] _autolayoutTrace]
i got the result that the two layout guides are already ambiguous
*<UIWindow:0x108f537f0> - AMBIGUOUS LAYOUT
| *<UIView:0x109409850>
| | *<_UILayoutGuide:0x109409c10> - AMBIGUOUS LAYOUT
| | *<_UILayoutGuide:0x10940a540> - AMBIGUOUS LAYOUT
Is there a reason to get rid of those warnings - or can i simply ignore them?
You can ignore them if you dont want to use Autolayout or go to the Interface Builder and add the layouts yourself (you can even let XCode add the layouts it thinks are needed)
It was the same with iOS 6.
I guess it sometimes takes time for constraints to "settle down" and not be ambiguous. According to WWDC 2012 video "Best Practices for Mastering Auto Layout," ambiguity can be temporarily tolerated (unlike unsatisfiability, which immediately raises an exception).
If you want to prove to yourself that your constraints are not remaining ambiguous, then create a wrapper for [[UIWindow keyWindow] _autolayoutTrace] and call it after a short delay:
- (void)viewDidAppear:animated
{
[super viewDidAppear:animated];
[self performSelector:@selector(wrapperForLoggingConstraints) withObject:nil afterDelay:.3];
}
- (void)wrapperForLoggingConstraints
{
[[UIWindow keyWindow] _autolayoutTrace];
}
You have to create a category on UIWindow in order to get this to work:
@interface UIWindow()
+ (UIWindow *)keyWindow;
- (NSString *)_autolayoutTrace;
@end
I put this category in its own header file, UIWindow_AutoLayoutDebug.h
Where ever I call [[UIWindow keyWindow] _autolayoutTrace] in my app, I import UIWindow_AutoLayoutDebug.h
I learned about calling [[UIWindow keyWindow] _autolayoutTrace] in code from the book "iOS 6 by tutorials", Volume 1, by the raywenderlich.com team. The idea of delaying the call is my own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With