2011-02-09 37 views
0

呼叫不會進入UIInterfaceOrientation委託方法,請幫助UIInterfaceOrientation方法不靈

這裏是代碼

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

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait) 
    { 
     NSLog(@"potrait"); 
    } 
    else 
    { 

    } 
} 

回答

4

您的視圖控制器是否在另一個視圖控制器內?

尋找Technical Q & A QA1688爲什麼我的UIViewController不能隨設備旋轉?在您的開發人員文檔中

這會給你一個暗示爲什麼它不適用於你的情況。

1

上週我有這個問題,這裏是我發現的。如果您使用的是標籤欄,那麼你必須有

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return YES; 
} 
在添加到TabBarController,以便其中的任何旋轉每個視圖控制器

。如果你只希望某些標籤旋轉,你還可以通過添加

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

有可能是一個類似的決議,如果你使用的是NavigationController做到這一點,但我還沒有到這個問題運行呢。