2013-01-11 21 views
0

我有一個永遠是肖像的iPhone應用程序。但我需要旋轉一個視圖來顯示一個表格。 該按鈕位於子視圖中。我有這樣的代碼:從子視圖更改界面方向 - iOS

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

但是因爲這種觀點是從子視圖調用接口的方向將被忽略。

有什麼辦法可以改變接口的方向?

謝謝!

回答

0

您是否嘗試過以下方法?

[UIApplication sharedApplication] .statusBarOrientation = UIInterfaceOrientationLandscapeRight;

+0

javiazo想旋轉一個特定的視圖,而不是狀態欄... – foundry

0

您需要在要旋轉的視圖上設置變換,然後將其設置回標識變換。

這將縱向和橫向之間切換...

UIView* viewToTransform = self.newview; 
    if (CGAffineTransformIsIdentity(viewToTransform.transform)) { 
     CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI/2); 
     viewToTransform.transform = transform; 

    }else{ 
     viewToTransform.transform = CGAffineTransformIdentity; 
    } 

更妙的是,保存現有的屬性轉換,以便以後可以重新設置(這將處理情況下,原來的變換不身份轉換)。

+0

我做到了,但它沒有結果,也許我需要一些進口?謝謝! – javiazo

+0

你試圖旋轉屏幕上的一切或只是一個子視圖? – foundry