Is there a way to skip rotation animation from shouldAutorotateToInterfaceOrientation?

I would like to enable orientation rotation according to the call toAutorotateToInterfaceOrientation for my view controller. However, I would like him to do this immediately and skip the spinning animation (the one that causes the corners to show a black spinning animation while the whole view is spinning.

Does anyone know if there is a way to indicate that you want this to happen immediately (without animation)?

+4
source share
2 answers

To do what you want, you must manually rotate (and resize) your view. There is no property that you can change to do whatever you want. Below is the code for registering device events.

- (void)viewDidLoad { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; //Whenever the device orientation changes, orientationChanged will be called } - (void)orientationChanged:(NSNotification *)notification { UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; //Based upon which orientation the device is in, update your View rotations. //A simple view.transform = CGAffineTransformMakeRotation(whatever); will work well. } 

I believe that you should completely remove the shouldAutoRotateToInterfaceOrientation: function. You must also call [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; when your view is unloaded.

+2
source

No manual rotation required. There is a way to simply turn off the rotation animation. .

Here is the answer on how to do this: fooobar.com/questions/1311466 / ...

0
source

Source: https://habr.com/ru/post/1315465/


All Articles