6

Hi I have a problem with rotation of an Modal presented ViewController in iOS8. All this works fine on iOS7 and lower.

App Struct:

  • RootController (supported Orientation: Portrait)
  • Modal Presented ViewController (supported Orientation: All)

My Problem is when I Rotate the Device when the Modal Controller is Presented the view of the Modal Controller didn't resize to the lanscape frame.

Looks like so:

enter image description here The Rotation methods was called and when I set the frame of the view to Landscape manually the user interaction of the right side (screen gray side) didn't 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 any one help me to fix this problem for iOS8.

AKHolland
  • 4,435
  • 23
  • 35
Zeropointer
  • 510
  • 2
  • 7
  • 24

1 Answers1

1

How are you presenting the modal view controller? Why are you forwarding the rotation methods yourself? When done properly, this should be handled automatically and all you need are the -supportedInterfaceOrientations methods (and as Jasper notes, the autoresizingMask, or Auto Layout constraints, need to be correct).

Ricky
  • 3,101
  • 1
  • 25
  • 33