到目前为止我还没有找到任何与我的情况相对应的东西......
仅供引用,我正在使用 Storyboard 为 iOS 5 开发。
我有一个 标签栏 Controller 与 2 次观看 在其中(我们称它们为选项卡 1 和选项卡 2)。我也有一个单独的风景查看, 没有标签栏 ,在应用程序使用期间设备旋转时使用。我使用在 shouldAutorotateToInterfaceOrientation
中手动启动的 segue切换到该 View 和从该 View 切换。我还在横向 View 中使用 NSString 来了解我来自哪个选项卡,以便在我返回纵向时返回更正一个选项卡。到目前为止,这工作正常。我可以完全按照我想要的方式来回切换横向模式。
我的问题是:
当我以纵向方式启动应用程序时,我会看到标签栏。如果我去风景,它就会消失。这很好,这就是我在 Storyboard中所做的。但是当我回到纵向时,标签栏不回来 !那就是问题所在。
编辑:调用旋转的代码
我停止使用 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,在进入横向之前设置,所以我知道我来自哪个 View ):-(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];
}
}
}
最佳答案
查看您的评论,我认为您的标签栏正在消失,因为您正在从未嵌入标签栏 Controller 的 View Controller (这是您的横向 View View Controller )中分离,我建议以下内容:
1) 设置 segue 以返回上一个 View 似乎很复杂,更不用说您正在创建更多 View / Controller 并将它们添加到堆栈中,因此请丢弃返回原始 View 的 segue。
2)使横向 View 的segues成为模态的,这样当你segue到它们时你不会显示标签栏,如果你使用push它将嵌入标签栏 Controller 中。
3)由于景观 View 将是一个模态视图,只需在景观 View Controller 的旋转代码中调用此方法:[[self presentingViewController] dismissModalViewControllerAnimated:YES];
这会将 View 推离堆栈并返回到它来自的 View 。
关于ios - 旋转后隐藏的标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12193082/