I need to disable orientation change animations on devices updated recently to iOS 16.
For older iOS versions there was a solution to prevent animations. The view hierarchy was changing instantly after disabling animations using the UIView
method:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
NSLog(@"breakpoint");
[UIView setAnimationsEnabled:NO];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
///
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[UIView setAnimationsEnabled:YES];
}];
}
After updating to iOS 16, the animation seems to begin before -viewWillTransitionToSize:withTransitionCoordinator:
is even called. For example, when I add a breakpoint in the code above, then on iOS 15 (and older) the window will remain unchanged before reaching the breakpoint. With iOS 16, the screen rotates to the new orientation before the breakpoint is hit.
Setting [UIView setAnimationsEnabled:NO];
permanently, at app launch cancels other animations, but the orientation change animations still take place. However, the orientation change animations look worse with permanently disabled animation, like only the views angle (rotation) was animated but not the scale / aspect.