IOS7: Update current orientation before animation completes

The overided viewWillTransitionToSize instance method did update the
current orientation when animation to the new orientation completed.
However, that made the handling of safe areas on devices having such,
e.g. iPhones with the sensor bar on top, racy. The correct orientation
was set after the adjustViewFrameForSafeArea function was called.

Set the new orientation before the animation completes.
This commit is contained in:
Lars Sundström 2023-07-08 09:10:40 +02:00
parent 34d7cd3769
commit 1b3c783b9e

View File

@ -88,14 +88,11 @@
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
UIInterfaceOrientation orientationAfter = [self interfaceOrientation];
if (orientationAfter != UIInterfaceOrientationUnknown && orientationAfter != currentOrientation) {
currentOrientation = orientationAfter;
[[iOS7AppDelegate iPhoneView] interfaceOrientationChanged:currentOrientation];
}
}];
}
#endif