UIViewController device rotation delegation methods are not called in iOS8

I am working on iOS 7 to make it compatible with ios 8 (beta 5). In this application, UIViewController ( vc1 ) introduces another UIViewController ( vc2 ). vc1 supports both portrait and landscape orientations; vc2 only supports portrait orientation. When vc2 is vc2 , it requests vc1 : shouldAutorotateToInterfaceOrientation: and this returns YES .

In iOS8 (beta 5), willRotateToInterfaceOrientation: and didRotateFromInterfaceOrientation: not called, as well as the new iOS 8 viewWillTransitionToSize . But this works great in iOS7.

I know that willAnimateRotationToInterfaceOrientation and didRotateFromInterfaceOrientation are deprecated in iOS 8, but even iOS 8 delegate methods are not called. Each time you start vc2 from vc1 , screens always load only in portrait mode, even if I mentioned the supported interface orientation as landscape left.

Any ideas ... is this a bug in iOS8?

+5
source share
1 answer

Well, I didn’t understand your problem better, but as soon as I have many lines that work perfectly with rotation in iOS 8.1, I will present them to you. They are simply taken and slightly edited from the Apple API reference.

I just put this in every VC, and I just edit the code when necessary. For example, I have an application that has an initial view controller on a portrait, and then changes the VC (segue completed) from LandscapeVC with various functions. These are portrait view methods that cause rotation in the LandscapeView.

 bool isShowingLandscapeView = false; - (void)awakeFromNib { isShowingLandscapeView = NO; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)orientationChanged:(NSNotification *)notification { UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView) { isShowingLandscapeView = YES; [self performSegueWithIdentifier:@"toLandscape" sender:self]; } 

Hope I made it easy to understand. Feel free to improve your answer, we all learn in this life!

+2
source

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


All Articles