2012-05-02 31 views
0

我正在構建一個iPad應用程序,所有視圖都應該自動旋轉。一種觀點讓我頭痛。ipad應用程序 - 大多數視圖旋轉確定。一個視圖不

我知道這個問題的變體已經被問了幾次前,但我無法通過調用應用程序的程序找到一個可行的解決方案..

我翻到這一觀點。代表。這個例程的代碼是:

- (void)flipToBack { 
    //NSLog(@"%s", __FUNCTION__); 

    DrawingViewController *drawView = [[DrawingViewController alloc] initWithNibName:@"Draw" bundle:nil]; 
    [self setDrawingViewController:drawView]; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES]; 

    [self.window addSubview:[drawView view]]; 
    [UIView commitAnimations]; 

    // NSLog (@" FINISHED "); 
} 

這是一個視圖控制器(mvc)與UIView子視圖,後者,繪圖發生。 mvc和子視圖都不能正常旋轉。

我使用調用在MVC旋轉的代碼是:

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

MVC的有兩個工具欄,頂部和底部,而這些都需要調整。無論輪換如何,這些也應該保持頂部和底部。

項目總結顯示所有方向都受支持,但我認爲這僅適用於應用程序。初始化。

我所有的支持mvc。

我正在創建的工具欄是這樣的:

UIInterfaceOrientation fieldOrient = [[UIApplication sharedApplication] statusBarOrientation]; 
    if ((fieldOrient == UIDeviceOrientationLandscapeLeft) || (fieldOrient == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 50, 1024, 35); 
     topToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 50, 768, 35); 
     topToolbar.frame = frame; 


UIInterfaceOrientation fieldOrient = [[UIApplication sharedApplication] statusBarOrientation]; 
    if ((fieldOrient == UIDeviceOrientationLandscapeLeft) || (fieldOrient == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 650, 1024, 35); 
     bottomToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 950, 768, 35); 
     bottomToolbar.frame = frame; 

我想我失去了一些東西明顯..任何幫助/指針將不勝感激。

回答

0

對我的答案是呈現視圖爲模式圖。這不是理想的,但它的工作原理。

1

嘗試在將旋轉到接口取向方法設置幀:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    if ((toInterfaceOrientation == UIDeviceOrientationLandscapeLeft) || (toInterfaceOrientation == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 650, 1024, 35); 
     bottomToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 950, 768, 35); 
     bottomToolbar.frame = frame; 
} 
+0

或者,您可以在創建工具欄時設置自動調整大小的蒙版。 – scord

+0

我很抱歉,但我已經增加了更多的問題,並可能會改變你的答案的代碼.. –

+0

我試過你的解決方案,但沒有喜悅:( –