2012-10-11 37 views
0

我在我的UIViewController中有下面的代碼,我正在測試設備中的iOS 5和兩個simultor。與shouldAutorotateToInterfaceOrientation有問題

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (IS_IPHONE){ 
     return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown; 
    } else { 
     return YES; 
    } 
} 

我把一個斷點,它確實被調用,但它仍然旋轉到風景。爲什麼是這樣?

回答

2

因爲你讓它這樣做。 return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;表示您想自動旋轉至的每個方向,但肖像倒置,和包括景觀。對於iPad而言,即使這個限制也沒有了,所以它會向任何方向進行追蹤。

(你應該有一口氣的文件......)

1

使用這個代替

回報(interfaceOrientation == UIInterfaceOrientationPortrait);