how to show and hide UISplitViewController with animation

允我心安 提交于 2019-12-11 13:17:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!