From 21de19443a02c280fde14e190163f921ba672acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Thu, 1 Oct 2020 22:49:54 +0200 Subject: [PATCH] fix broken view after interactive sheet dismiss on iOS 13 --- Mini vMac/ViewController.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Mini vMac/ViewController.m b/Mini vMac/ViewController.m index 319b109..f9e2215 100644 --- a/Mini vMac/ViewController.m +++ b/Mini vMac/ViewController.m @@ -13,7 +13,7 @@ #import "KBKeyboardView.h" #import "KBKeyboardLayout.h" -@interface ViewController () +@interface ViewController () @end @@ -74,6 +74,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UISwipeGestureRecognizer *gestureRecognizer = (UISwipeGestureRecognizer*)sender; modalPanePresentationDirection = gestureRecognizer.direction; segue.destinationViewController.transitioningDelegate = self; + segue.destinationViewController.presentationController.delegate = self; } else if (self.presentedViewController != nil && [@[@"disk", @"settings"] containsObject:segue.identifier]) { [self dismissViewControllerAnimated:YES completion:nil]; } @@ -116,6 +117,19 @@ - (void)animateTransition:(id)transitionCo }]; } +- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController { + // hack to fix the presenting view controller not returning back to normal size on iOS 13 + // when the sheet is dismissed interactively (ie dragging it down) after a contextual menu + // has been shown, which breaks some autolayout constraints. when this happens, the + // presenting view controller won't resize back to normal during the interactive + // dismissing of the presented sheet + if (@available(iOS 14, *)) { + // it works correctly on iOS 14 + } else { + self.view.superview.transform = CGAffineTransformIdentity; + } +} + - (BOOL)prefersStatusBarHidden { UIScreen *screen = self.view.window.screen; return CGRectEqualToRect(screen.bounds, self.view.window.bounds);