Modal ViewController iOS8 rotation issue

Hey. I have a problem with the rotation of the presented ViewController in the iOS8 module. All this works fine on iOS7 and below.

App Struct:

  • RootController (orientation supported: portrait)
  • Modal Presented by ViewController (supported Orientation: All)

My problem is when I rotate the device when the Modal Controller is displayed, the Modal Controller view has not changed to the lanscape frame size.

Looks like that:

enter image description here The Rotation methods were called, and when I manually set the view frame to Landscape, the user interaction on the right side (gray side of the screen) did not work.

RootController Code:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } - (NSUInteger) supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

Modal controller code:

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (self.presentingViewController != nil) { [self.presentingViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; } } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (self.presentingViewController != nil) { [self.presentingViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; } } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { if (self.presentingViewController != nil) { [self.presentingViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; } } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { } completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { }]; } 

Can someone help me fix this issue for iOS8.

+6
source share
1 answer

How do you represent the modal view controller? Why are you sending rotation methods yourself? When everything is done correctly, it needs to be processed automatically, and all you need is the -supportedInterfaceOrientations methods (and as Jasper notes, autosave restrictions or auto layout should be correct).

+1
source

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


All Articles