motion-transitioning-objc icon indicating copy to clipboard operation
motion-transitioning-objc copied to clipboard

MDMTransitionPresentationController should implement viewWillTransitionToSize

Open jverkoey opened this issue 8 years ago • 1 comments

frameOfPresentedViewInContainerView is unfortunately only called during the initial presentation of a view controller, meaning a view controller that's presented over part of the screen won't know to update its layout when the device's orientation changes.

To solve this, we can implement viewWillTransitionToSize and invoke _calculateFrameOfPresentedView with the new dimensions. This will allow the block to return a new size for the new dimensions.

Unfortunately, some quick sleuthing revealed that the containerView's frame isn't up-to-date when viewWillTransitionToSize is invoked and, because our block implementations tend to look at the containerView's bounds, most of our layout blocks will probably be wrong.

jverkoey avatar Oct 25 '17 19:10 jverkoey

I believe you want to query the frame as you animateAlongsideTransition inside your PresentationController.

-(void)viewWillTransitionToSize:withTransitionCoordinator: { // Call super ...

[coordinator animateAlongsideTransition: ^() { // self.contentView.frame should be current now self.presentedView.frame = [self frameOfPresentedViewInContainerView]; } }

ianegordon avatar Oct 25 '17 23:10 ianegordon