平滑动画隐藏并在拆分视图控制器中显示主视图控制器

时间:2013-12-14 08:59:15

标签: ios objective-c ipad animation uisplitviewcontroller

我正在使用UISplitViewController开发iPad应用程序。我想按需显示/隐藏Master View Controller。我看过How to hide & unhide Master View Controller in SplitView ControllerAnimate visibility of master detail controller of UISplitViewController,所以我想出了类似的东西:

我的hideMasterView中有BOOL UISplitViewControllerDelegate个变量,当我想显示/隐藏主视图时,我打电话:

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) {}];

我的代表有方法:

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

它有效,但动画不是很顺畅。隐藏一切正常,但显示主视图时,细节视图在滑动前调整大小,在右侧留下空白灰色空间,然后在其上滑动

如何修复此动画?

0 个答案:

没有答案