xcode 2 个不同的纵向和横向故事板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9647548/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
2 different storyboards for portrait and landscape
提问by Alessandro
is it possible to create 2 storyboards and access each of them depending on the device orientation? I tried this code:
是否可以创建 2 个故事板并根据设备方向访问每个故事板?我试过这个代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
if (UIInterfaceOrientationPortrait){
UIStoryboard *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Storyboardland.storyboard"];
}else if (UIInterfaceOrientationPortraitUpsideDown){
UIStoryboard *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"MainStoryboard_iPad.storyboard"];
}}
...but does not work?? Any errors I am making??
...但不起作用?我犯的任何错误?
采纳答案by T.J.
I think this answer to a previous post (iPhone Storyboard: different scene for portrait and landscape)might solve your problem. It explains how to have a different views for portrait and landscape modes, but still uses the same view controller.
我认为这个对上一篇文章的回答(iPhone Storyboard:人像和风景的不同场景)可能会解决您的问题。它解释了如何为纵向和横向模式使用不同的视图,但仍然使用相同的视图控制器。