2

Just as the title said. In iOS 9, all the methods in category (in UIViewController.h):

@interface UIViewController (UIViewControllerRotation)

has been deprecated.

So here is the question: How to detect UIViewController rotation events in iOS 9

mayqiyue
  • 1,155
  • 1
  • 10
  • 16

2 Answers2

2

The iOS 8 method of detecting orientation change (rotation) is implementing the following method of the view controller:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

{
    // Do view manipulation here.
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

Note: The controller's view has not yet transitioned to that size at this time, so be careful if your sizing code relies on the view's current dimensions.

It will also applied iOS 9

Source:https://stackoverflow.com/a/27700245/2963912

Community
  • 1
  • 1
techloverr
  • 2,597
  • 1
  • 16
  • 28
0

You can use the methods avaliable in the UIDevice

beginGeneratingDeviceOrientationNotifications()

You must call this method before attempting to get orientation data from the receiver. This method enables the device’s accelerometer hardware and begins the delivery of acceleration events to the receiver. The receiver subsequently uses these events to post UIDeviceOrientationDidChangeNotification notifications when the device orientation changes and to update the orientation property.

Ulysses
  • 2,281
  • 1
  • 16
  • 24