我正在使用UISplitViewController
开发iPad应用程序。我想按需显示/隐藏Master View Controller。我看过How to hide & unhide Master View Controller in SplitView Controller和Animate 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;
}
它有效,但动画不是很顺畅。隐藏一切正常,但显示主视图时,细节视图在滑动前调整大小,在右侧留下空白灰色空间,然后在其上滑动。
如何修复此动画?