how to show and hide UISplitViewController with an

2019-08-10 01:52发布

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条回答
仙女界的扛把子
2楼-- · 2019-08-10 02:32

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

查看更多
登录 后发表回答