2010-08-09 48 views
0

首先 - 我读了所有类似的话题,而不是他们为我工作。 我有几个视图控制器。我改变他们的代码:iPhone力的方向

- (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度)后才变为景观。如何强制应用以横向模式显示所有视图?

UPD:

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

回答

0

有两种景观模式和两种肖像模式。一个是左侧风景,另一个是风景右侧。例如,如果您从横向左侧翻转到其中一个纵向模式(假设底部有home按钮),您将旋转270度。

至于如何强制您的意见留在景观(挑两种模式之一),就这样做:

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

这总会引起横向左排列来显示这一观点。

+0

更正 - 仅适用于来自UPD的代码。 – Andoriyu 2010-08-10 00:43:02