2

I am developing iPad application using UISplitViewController. I want to show/hide Master View Controller on demand. I have seen How to hide & unhide Master View Controller in SplitView Controller and Animate visibility of master detail controller of UISplitViewController, so I came up with something like this:

I have hideMasterView BOOL variable in my UISplitViewControllerDelegate and when I want to show/hide Master View I call:

hideMasterView = !hideMasterView;
[UIView animateWithDuration:0.25
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                          [self.splitViewController willAnimateRotationToInterfaceOrientation:self.interfaceOrientation duration:0];
                          [self.splitViewController willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
                          [self.splitViewController didRotateFromInterfaceOrientation:self.interfaceOrientation];
                          [self.splitViewController viewWillLayoutSubviews];
                          [self.splitViewController.view layoutSubviews];
                      }
                 completion:^(BOOL finished) {}];

And my delegate has method:

- (BOOL)splitViewController:(UISplitViewController *)svc
   shouldHideViewController:(UIViewController *)vc
              inOrientation:(UIInterfaceOrientation)orientation{
    return hideMasterView;
}

It works, but animation is not quite smooth. On hide everything works fine, but when Master View is being shown, Detail View is resized before sliding, leaving blank gray space on right and sliding on it afterwards.

How to fix this animation?

Community
  • 1
  • 1
Crazy Yoghurt
  • 2,365
  • 2
  • 26
  • 37

0 Answers0