2010-08-09 72 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