Skip to content

Commit

Permalink
fix broken view after interactive sheet dismiss on iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
zydeco committed Oct 1, 2020
1 parent 479b9c2 commit 21de194
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Mini vMac/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "KBKeyboardView.h"
#import "KBKeyboardLayout.h"

@interface ViewController () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning>
@interface ViewController () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning, UIAdaptivePresentationControllerDelegate>

@end

Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -116,6 +117,19 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)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);
Expand Down

0 comments on commit 21de194

Please sign in to comment.