到目前为止我还没有找到任何与我的情况相对应的东西......
仅供参考,我正在使用情节提要为 iOS 5 开发。
我有一个带有2 个视图的选项卡栏控制器(我们称它们为选项卡 1 和选项卡 2)。我还有一个单独的横向视图,没有标签栏,在应用程序使用期间设备旋转的任何时候都会使用它。我使用手动启动的 segue来切换到这个视图。我还在横向视图中使用 NSString 来了解我来自哪个选项卡,以便在我返回纵向时返回更正一个选项卡。到目前为止,这工作正常。我可以完全按照我想要的方式来回切换横向模式。shouldAutorotateToInterfaceOrientation
我的问题是:
当我以纵向方式启动应用程序时,我会看到标签栏。如果我去风景,它就会消失。这很好,这就是我在故事板中所做的。但是当我回到肖像时,标签栏没有回来!那就是问题所在。
编辑:调用旋转的代码
我停止使用shouldAutorotateToInterfaceOrientation
旋转,因为它与自定义 segues 冲突。标签栏的问题以前就在这里,所以这不是问题。我didRotate
改用。
这是来自FirstViewController.m
(相同的代码SecondViewController.m
,更改我的 segue 标识符)的代码:
-(void)didRotate:(NSNotification *)notification
{
UIInterfaceOrientation newOrientation = [[UIDevice currentDevice] orientation];
if ((newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight))
{
[self performSegueWithIdentifier: @"Page1ToLandscapeSegue" sender: self];
}
}
从LandscapeViewController.m
(previousView
是一个 NSString,在进入横向之前设置,所以我知道我来自哪个视图):
-(void)didRotate:(NSNotification *)notification
{
UIInterfaceOrientation newOrientation = [[UIDevice currentDevice] orientation];
if (newOrientation == UIInterfaceOrientationPortrait)
{
if ([previousView isEqualToString: @"View1"]) {
[self performSegueWithIdentifier: @"LandscapeToPage1Segue"
sender: self];
}
else if ([previousView isEqualToString: @"View2"]) {
[self performSegueWithIdentifier: @"LandscapeToPage2Segue"
sender: self];
}
}
}