具有模态视图的横向模式

时间:2012-08-22 23:50:15

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

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

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

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

我的模态视图以横向模式显示,但下方的视图以纵向显示。模态被解散后,视图仍然在potrait中。如果我没有将模态附加到视图,则视图在横向模式下显示正常。

我使用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;
}

1 个答案:

答案 0 :(得分:0)

快速说明:presentModalViewController:animated:已弃用。 Apple建议使用presentViewController:animated:completion:

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

相关问题