View unusable after dismissViewControllerAnimated:completion:

后端 未结 4 1650
孤城傲影
孤城傲影 2021-01-05 07:08

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

相关标签:
4条回答
  • 2021-01-05 07:59

    I have also the same problem and when i tried this navigation controller it was working fine but not with present viewcontroller. Use this below view controller method along with translatesAutoresizingMaskIntoConstraints to solve this problem.

    -(void) viewWillLayoutSubviews
    {
        [super viewWillLayoutSubviews];
    
        self.view.translatesAutoresizingMaskIntoConstraints = NO;
    }
    

    Please let me now it you have any concern about it. Thanks

    0 讨论(0)
  • 2021-01-05 08:10

    A different solution - I found if presenting from a view controller within a container view (as opposed to a subview), if you switch the segue from Modal to Show, your constraints will stay the same on your initial view but still animate as if you presented modally and still be able to call dismissViewController correctly.

    0 讨论(0)
  • 2021-01-05 08:12

    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.

    0 讨论(0)
  • 2021-01-05 08:13

    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.

    0 讨论(0)
提交回复
热议问题