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
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
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
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.