presenting a full screen viewcontroller from inside a formsheet
Closed this issue · 1 comments
How do i present a full screen viewcontroller from inside a viewcontroller that is being presented by MZFormSheetPresentationViewController.
It actually presents the full screen viewcontroller but when we rotate screen while being on this new presented viewcontroller and then dismiss this viewcontroller then the formsheet doesn't appear rotated and centred on the screen.
@m1entus
@yklishevich
Here is the formsheet when we don't rotate the device
Here is the formsheet when we do rotate the device after presenting a viewcontroller from inside the formsheet and then dismissing it, it's not centred on the screen.
also attached the sample project
TestingApplication.zip
Okay, I've managed to fix it myself.
Here is the solution for anyone else facing the same issue.
Update the setFrame:(CGRect)frame method implementation inside MZFormSheetPresentationViewControllerCustomView like this
- (void)setFrame:(CGRect)frame {
// This is workaroud for UIViewControllerBuiltinTransitionViewAnimator
// who is setting frame to [UIScreen mainScreen] when modally presented over
// MZFormSheetPresentationViewController using UIModalPresentationFullScreen style !!!
// Made this workaround to have less github issues, for people who is not reading docs :)
if (self.viewController.presentedViewController && self.viewController.presentedViewController.modalPresentationStyle == UIModalPresentationFullScreen) {
if(CGSizeEqualToSize(frame.size, [UIScreen mainScreen].bounds.size))
return;
else{
frame.origin = CGPointMake(([UIScreen mainScreen].bounds.size.width - frame.size.width) / 2, ([UIScreen mainScreen].bounds.size.height - frame.size.height) / 2);
[super setFrame:frame];
}
}
// This is workaroud for UIViewControllerBuiltinTransitionViewAnimator
// who is setting frame to [UIScreen mainScreen] when modally presented over
// MZFormSheetPresentationViewController using UIModalPresentationCurrentContext style !!!
if (self.viewController.presentedViewController && self.viewController.presentedViewController.modalPresentationStyle == UIModalPresentationCurrentContext) {
return;
}
[super setFrame:frame];
}