2

I have one UIViewController in which another viewcontroller(1) and splitviewcontroller(2) do switching via addchildviewcontroller method. So when I add splitviewcontroller it doesn't handle correct the rotations. Look at the video – https://dl.dropbox.com/u/2139277/IMG_0180.MOV.

Here is the code that does switching:

- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController
{
    if (fromViewController == toViewController)
        return;
    // animation setup
    toViewController.view.frame = self.view.bounds;
    // notify
    [fromViewController willMoveToParentViewController:nil];
    [self addChildViewController:toViewController]; 
    // select animation direction
    UIViewAnimationOptions animation = (_contentState == ContentStateViewingMap) ? UIViewAnimationOptionTransitionCurlUp : UIViewAnimationOptionTransitionCurlDown;
    // transition
    ContentState previousState = _contentState;
    _contentState = ContentStateAnimating;
    [self transitionFromViewController:fromViewController
                      toViewController:toViewController
                              duration:0.6
                               options:animation | UIViewAnimationOptionCurveEaseInOut
                            animations:nil
                            completion:^(BOOL finished) {
                                [toViewController didMoveToParentViewController:self];
                                [fromViewController removeFromParentViewController];
                                _contentState = (previousState == ContentStateViewingMap) ? ContentStateViewingList : ContentStateViewingMap;
                            }];
}
user125559
  • 21
  • 1

1 Answers1

0

AFAIK a UISplitViewController MUST be the root view controller of the window. Adding it as child view controller is not supported.

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
  • But it works great when i add it to tabbarcontroller in stotyboard – user125559 Dec 13 '12 at 19:51
  • Still, it is not intended to be used like that and if you insist on using it differently than Apple has designed it for then you will find all sorts of things not behaving as you might expect. Apple calls this "the behavior is undefined." – Cocoanetics Dec 13 '12 at 19:54