答案是动画的preferredDisplayMode属性。要显示的代码是:
if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) {
[UIView animateWithDuration:ANIMATION_LENGTH animations:^{
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryOverlay;
} completion:^(BOOL finished) {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
}];
}
和隐藏代码:
if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) {
[UIView animateWithDuration:ANIMATION_LENGTH animations:^{
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
} completion:^(BOOL finished) {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
}];
}
我把它设回自动在完成这样的拆分视图控制器可以做正常的事情后,动画完成。我还为展会添加了另一个布尔值,所以我只显示它,如果我的细节项目尚未设置,但我从上面的代码中删除它,因为这是特定于您自己的代码。
正是我在找什么,但我不得不删除完成位,否则它只是跳回到主可见再次。 – trapper 2016-01-08 04:37:51
在Xcode 7.3中,[UIDevice currentDevice] .orientation'给出错误消息。我建议编辑将这些事件更改为'[UIApplication sharedApplication] .statusBarOrientation'? – David 2016-04-17 20:57:51
此外,此动画现在导致细节表视图的不良动画。 – David 2016-04-17 21:03:30