呈现ModalViewController会在启动时改变我的应用程序的方向

时间:2012-02-07 21:16:11

标签: iphone

我试图只支持景观。有一个新要求显示此对话框,第一次解释有关我们的应用程序的一些事情。所以在我启动的第一个视图控制器中,在viewDidLoad中,我有这个代码:

BOOL showFirstTimeUse = [[NSUserDefaults standardUserDefaults] boolForKey:@"ShowFirstTimeUse"];
if (!showFirstTimeUse) {
    FirstUseViewController *tvc = [[FirstUseViewController alloc] initWithNibName:@"FirstUseViewController" bundle:nil];
    tvc.modalPresentationStyle = UIModalPresentationFormSheet;
    tvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:tvc animated:YES];
    [tvc release];
}

然后在FirstUseViewController中,我定义了这个:

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

在IB中,我没有更改任何默认设置。我基本上只是将UIWebView放到屏幕的左上角以显示我的数据并连接到它的插座,这样我就可以轻松地显示格式化的文本。

当我现在运行我的应用程序时,此视图控制器的演示会导致我的应用程序以纵向而非横向开始。我该如何解决?感谢。

1 个答案:

答案 0 :(得分:0)

shouldAutorotateToInterfaceOrientation:的实施有误;它总是会评估为真。您可能想要使用:

return UIInterfaceOrientationIsLandscape(interfaceOrientation);
相关问题