1

我有一个作为通用 iPad/iPhone 应用程序创建的 iPhone 应用程序。我已经为 iPad 版本实现了一个 splitviewcontroller ......一切都很好。

在我的 iPhone 应用程序中,除了第二级视图控制器(Web 视图)之外,所有内容都是纵向的,我重写了 shouldAutorotateToInterfaceOrientation 以允许横向。返回视图链后,我回到肖像..太棒了!

但是,现在我的 iPad 拆分视图应用程序被迫保持纵向。如果我在我的任何视图(如 rootviewcontroller 或其他视图)中覆盖 shouldAutorotateToInterfaceOrientation ,它会有效地允许我的 iPhone 应用程序中的横向模式,这是我无法做到的。但是它确实解决了我在 iPad 中的横向问题。

有办法解决这个问题吗?我实际上想对 iPad 的 shouldAutorotateToInterfaceOrientation 说“是”,但对 iPhone 说“是”。我试过这个,但它不起作用,它允许在两个设备上使用横向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    BOOL rotate = NO;
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        rotate = YES;
    }
    return rotate;  
}

有什么建议吗?

4

1 回答 1

1
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
} else {
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
于 2010-11-19T13:50:30.953 回答