Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View unusable after dismissViewControllerAnimated:completion:

I'm migrating older code that used NIBs to use manual view creation (loadView) and Auto Layout. The root view controller is a container VC (with 2 children) that uses auto layout and modally presents a view controller that has its layout specified in a NIB and does not yet use auto layout. All is fine after presentViewController:animated:completion:, but when the modal view is closed with dismissViewControllerAnimated:completion: via delegate call, the presenting view is left in a strange, unusable state where the content is weirdly shifted and does not react to touch.

I have tried to create minimal test case to reproduce the problem, but I've failed to reproduce the issue.

What could be causing this?

like image 243
Palimondo Avatar asked Aug 09 '13 22:08

Palimondo


2 Answers

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

like image 158
Palimondo Avatar answered Nov 23 '22 05:11

Palimondo


I had problems with this when upgrading to IOS 11. The UICollectionView layout was not showing the cells anymore. Fixed by adding the line:

controller.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:controller animated:YES completion:nil];

Not sure why this fixes it but not giving it a presentation style really messes with the presenting controllers underlying layout.

like image 31
Md1079 Avatar answered Nov 23 '22 05:11

Md1079