UIViewControllerAnimatedTransitioning with Safe Area Insets on iPhone X

后端 未结 1 1128
名媛妹妹
名媛妹妹 2021-01-18 01:28

When animateTransition is called on the transitioning delegate the Safe Area Insets have yet to be set on the \'to view controller\'.

I\'ve tried forci

1条回答
  •  醉话见心
    2021-01-18 02:12

    Ensure that the destination view controller is actually in the view hierarchy when you call layoutIfNeeded. I had this same problem, oddly only affecting certain orientations, and fixed it by adding the second and third lines below:

    UIViewController * toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    
    // Added these two lines:
    toViewController.view.frame = [transitionContext finalFrameForViewController:toViewController];
    [transitionContext.containerView addSubview:toViewController.view];
    
    [toViewController.view setNeedsLayout];
    [toViewController.view layoutIfNeeded];
    

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