我想在我的 iPAD 应用程序上支持横向和纵向方向,该应用程序使用情节提要,而不涉及Auto LayoutoniOS6+和Auto ResizingoniOS 5和更早的复杂性(因为该应用程序将同时支持 iOS 5 和 6,所以AutoLayout这里不允许),我想到了什么作为解决方案的起点如下:
创建两个单独的故事板:MainStoryboard-Portrait& MainStoryboard-Landscape,当当前视图控制器(我们将其命名为 FirstViewController)是纵向的,并且用户将设备旋转到横向时,我从故事板中instantiate新建一个,反之亦然,当用户旋转回纵向时。我在方法中做了这样的事情:FirstViewControllerMainStoryboard-LandscapewillRotateToInterfaceOrientationFirstViewController.m
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard-Landscape" bundle:[NSBundle mainBundle]];
FirstViewController *VC = [storyboard instantiateViewControllerWithIdentifier:@"VC1"];
self.view = VC.view;
但是在 iOS6+: 上发生了以下崩溃A view can only be associated with at most one view controller at a time!,在 iOS5 上也尝试过,不会崩溃但旋转无法正常工作:窗口边界旋转但视图本身保持原样。
如何让它在 iOS 5 和 6 上运行?或者如果有其他更好的方法,请为我提供一个工作代码示例,我将奖励你 50 分。