Objective c 通过更改代理根视图控制器切换视图

Objective c 通过更改代理根视图控制器切换视图,objective-c,delegates,switching,rootview,Objective C,Delegates,Switching,Rootview,我目前正在尝试将视图从UIViewController切换到SplitViewController。我目前正在UIViewController中执行此操作: AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [UIView transitionWithView:delegate.window duration:0.5 options:UIViewAnimationOption

我目前正在尝试将视图从UIViewController切换到SplitViewController。我目前正在UIViewController中执行此操作:

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[UIView transitionWithView:delegate.window duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
    delegate.window.rootViewController = delegate.splitViewController;
} completion:nil];

[self.view removeFromSuperview];
这是切换视图的正确方式吗?如果是,我仍然有一个问题需要用这种方法解决。 它首先以纵向模式快速显示MasterView,然后以iPad当前的方向模式显示整个分割视图

我希望我足够清楚


谢谢您的帮助。

我找到了一种方法,可以从该线程开始工作:


我找到了一种方法,使它从该线程工作:

AppDelegate *delegate =(AppDelegate *)[[UIApplication sharedApplication] delegate];
[UIView transitionWithView:self.window duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
    BOOL oldState = [UIView areAnimationsEnabled];
    [UIView setAnimationsEnabled:NO];
    delegate.window.rootViewController = self.splitViewController;
    [UIView setAnimationsEnabled:oldState];
 } 
 completion:nil];