问题
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;
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
回答1:
Try it this way:
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){
}];
You can specify different animation types with the options
parameter
来源:https://stackoverflow.com/questions/17336019/how-to-show-and-hide-uisplitviewcontroller-with-animation