4
votes

I have a problem with rotation in iOS8. In iOS7, it's fine.

Sample download : https://www.dropbox.com/s/jr067r3jpzit10h/Rotation.zip?dl=0

The steps are following.

  1. create tab bar based iOS project in XCode 6.
  2. set device orientations to support Portrait, Landscape Left, Landscape Right in project setting.
  3. let the tab bar controller support Portrait only by code.(shouldAutorotate returns true and supportedInterfaceOrientations returns UIInterfaceOrientationMask.Portrait)
  4. present a view controller from the first view controller in tab bar, by presentViewController:animated:completion. use custom transition by setting transitioningDelegate.(I made a simple fade in/out transitioning delgate for this) the modal view support all kinds of orientation.(shouldAutorotate returns true)
  5. In the modal view, rotate the device.
  6. dismiss the modal view.
  7. view crashed like this.

enter image description here

anyone can help?

2

2 Answers

0
votes

I have something similar but I put the TabController in a navigation controller and in my custom navigation controller do this:

- (BOOL)shouldAutorotate {
return self.topViewController.shouldAutorotate;

}

0
votes

I ran into this issue also, very similar output to yourself - The only way I have found to avoid the issue so far is to ignore size changes for presenting view controllers on iOS 8.

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

    UIDevice *device = [UIDevice currentDevice];

    if ([device oka_iOS8] && self.presentingViewController) {
        [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    }

}

iOS8 can be determined however you want, I used a category on UIDevice.

    BOOL isLessThan9 = [device.systemVersion compare:@"9.0" options:NSNumericSearch] == NSOrderedAscending;

    NSComparisonResult result = [device.systemVersion compare:@"8.0" options:NSNumericSearch];

    BOOL isMoreThanOrEqualTo8 = result == NSOrderedSame || result == NSOrderedDescending;

The important part here is ignoring the call to the super implementation when presenting a view controller.

I placed this logic in a UINavigationController subclass which is used when presenting the viewController.