【问题标题】:iPhone force orientationiPhone 强制方向
【发布时间】:2011-03-27 13:42:06
【问题描述】:

首先 - 我阅读了所有类似的主题,但没有一个对我有用。 我的视图控制器很少。我通过该代码更改它们:

- (void)flipToAzbukaMenu {
    AzbukaMenuController *aAzbukaMenu = [[AzbukaMenuController alloc] initWithNibName:@"AzbukaMenu" bundle:nil];
    [self setAzbukaMenuController:aAzbukaMenu];
    [aAzbukaMenu release];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:window cache:NO];
    [viewController.view removeFromSuperview];
    [azbukaArcadeController.view removeFromSuperview];
    [self.window addSubview:[azbukaMenuController view]];

    [UIView commitAnimations];
}

我在 plist 中有正确的键,可以让我以横向模式启动应用程序。当应用程序启动时它具有正确的方向(横向),但是当我改变我的视图时,它变成纵向并且只有在将设备旋转 270 度(不是 90 度哈哈)后才再次变成横向。如何强制应用以横向模式显示所有视图?

更新:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown))
    {
        return NO;
    }
    if ((interfaceOrientation==UIInterfaceOrientationLandscapeLeft)||(interfaceOrientation==UIInterfaceOrientationLandscapeRight))
    {
        return YES;
    } else {
        return YES;
    }
}

【问题讨论】:

    标签: objective-c iphone


    【解决方案1】:

    有两种横向模式和两种纵向模式。一个是左边的风景,另一个是右边的风景。例如,如果您从左侧横向切换到其中一种纵向模式(例如,底部有主页按钮),您将获得 270 度旋转。

    至于如何强制您的视图保持在横向(选择两种模式中的一种),只需执行以下操作:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    

    这将始终导致该视图以横向左方向显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多