Auto layout invalid after presenting view controller (and many situation) [duplicate] Auto layout invalid after presenting view controller (and many situation) [duplicate] ios ios

Auto layout invalid after presenting view controller (and many situation) [duplicate]


I had a similar problem. I was setting translatesAutoresizingMaskIntoConstraints = NO; on my root UIView.It appears the "outermost" UIView - the superview at the root of your hierarchy must use the default translatesAutoresizingMaskIntoConstraints = YES.Once I've removed this, everything worked as expected.


It is probably caused by ambiguous constraints. I recommend pause a running application and type a following command to console:

po [[UIWindow keyWindow] _autolayoutTrace] 


If you use auto layout between the UIWindow and your root view (to set the root view to fill the entire UIWindow) these constraints will get blown away by a full screen presentation of another view controller.

What happens, is the entire hierarchy of the full-screen presentation replaces everything below UIWindow - your original view is removed (blowing away the constraints) and the new view hierarchy substituted. Then when your review is replaced, these constraints are lost. You would need to recreate them somewhere like viewWillAppear: or just ensure your root view has self.view.translatesAutoresizingMaskIntoConstraints = NO;


matomo