【问题标题】:Landscape mode with modal view带模态视图的横向模式
【发布时间】:2012-08-22 23:50:15
【问题描述】:

我正在尝试向我的 ipad 应用程序添加模式视图。所有视图都应该处于横向模式。 对于样式,我选择了表单或页面表。

这就是问题所在。当我使用以下代码将模态视图添加到我的视图时:

TempController *tmpViewController = [[TempController alloc] initWithNibName:@"TempView" bundle:nil];
tmpViewController.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:tmpViewController animated:YES];

我的模态视图以横向模式显示,但其下方的视图以纵向模式显示。在模态被解雇后,视图仍然处于肖像中。如果我不将模式附加到视图,则视图会以横向模式正常显示。

我玩过 statusBarOrientation 和 shouldAutootateToInterfaceOrientation,但还是没有运气。我在 Mountain Lion 上运行 xcode 4.4.1

更新:这是我的 shouldAutorotateToInterfaceOrientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    return YES;
}
return NO;
}

【问题讨论】:

    标签: objective-c xcode osx-mountain-lion ios5.1


    【解决方案1】:

    快速说明:presentModalViewController:animated: 已弃用。苹果推荐使用presentViewController:animated:completion:

    为了确保我理解这个问题,呈现模态视图控制器的视图控制器在横向模式下正确显示,但一旦呈现模态,它就会自行更改为纵向模式,即使模态视图控制器也显示在风景中正确吗?这是否发生在 iPhone/iPod touch 或 iPad 上? presenting 视图控制器的 shouldAutoRotateToInterfaceOrientation 方法的代码是什么样的?

    【讨论】:

    • 其实我把presentModal改成了presentViewController,还是一样的问题。
    • 将 shouldAutorotateToInterfaceOrientation 添加到我原来的帖子中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多