问题描述
我的应用程序中当前窗口的 rootViewController
是 MainViewController
。并且在另一个视图控制器中有一个按钮叫做 SubViewController
,如果用户单击按钮,我想显示 UISplitViewController
。我已经实现它如下:
The current rootViewController
of window in my app is MainViewController
. and there's a button in another view controller called SubViewController
, I want to show UISplitViewController
if a user click the button. I have implemented it as following:
//SubViewController.m
UISplitViewController *splitVC =[self splitVC];
self.view.window.rootViewController = splitVC;
没有动画可显示 splitVC
需要显示它与幻灯片样式,例如,滑动 SubViewController
.view到右边显示 UISplitViewController
如果用户单击 UISplitViewController
上的按钮,以回退 SubViewController.view
there's no animation to show splitVC
, I need to show it with slide style, example, to slide the SubViewController
.view to right to show the UISplitViewController
, and if the user click a button on UISplitViewController
, to slide back the SubViewController.view
推荐答案
尝试这样:
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController *splitVC =[self splitVC];
[UIView transitionWithView:self.view.window
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
appDelegate.window.rootViewController = splitVC;
}
completion:^(BOOL finished){
}];
您可以使用选项指定不同的动画类型
参数
这篇关于如何用动画显示和隐藏UISplitViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!