首先,我想说这个问题并没有解决我的问题:Orientation problem when I set a RootViewController
我的 ipad 应用程序只能在横向模式下工作。当我更改根控制器时,新的故事板会正确显示。但是,它以纵向模式出现,然后旋转到正确的方向。如何在更改根控制器之前指定方向或告诉故事板默认以横向显示?在动画之后看到视图的旋转非常难看。
此外,左右景观在项目属性中设置。
这是我更改根视图控制器时的代码。
UIStoryboard *editorStoryboard = [UIStoryboard storyboardWithName:@"EditorStoryboard" bundle:nil];
UISplitViewController *editorViewController = [editorStoryboard instantiateInitialViewController];
UINavigationController *navigationController = [editorViewController.viewControllers lastObject];
editorViewController.delegate = (id)navigationController.topViewController;
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[UIView transitionWithView:appDelegate.window duration:0.5 options: UIViewAnimationOptionTransitionFlipFromLeft animations:^{
appDelegate.window.rootViewController = editorViewController;
} completion:nil];