Change or disable the iPhone rotating animation when orientation changes

后端 未结 3 614
渐次进展
渐次进展 2021-02-06 06:10

How do I change or disable the rotating animation when screen orientation changes from landscape to portrait, or vice versa?

3条回答
  •  滥情空心
    2021-02-06 07:04

    If you dont want your view controllers to rotate just override the shouldAutoRotateToInterface view controller method to return false for whichever orientation you dont want to support...Here is a reference.

    In the case that u just want to handle rotation some other way, you can return false in the above methods and register for UIDeviceOrientationDidChangeNotification like so

        NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self
           selector:@selector(handleOrientationDidChange:)
               name:UIDeviceOrientationDidChangeNotification
             object:nil];
    

    Now when u get the notifications u can do whatever you want with it...

提交回复
热议问题