2012-04-02 30 views
0
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return YES; 
} 

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

不工作,我不知道,爲什麼。 當我嘗試調試並旋轉設備時,這些方法不會被調用。shouldAutorotateToInterfaceOrientation not working

我只想檢測取向 如果方向=景觀 執行行動 其他 輪換執行動作b

非常感謝

+1

你設定所有方向在您的項目設置支持? – Clafou 2012-04-02 16:28:35

+0

是的,我已經在plist。 – iscavengers 2012-04-02 16:29:37

+0

什麼是你的視圖層次結構?這應該是在頂視圖控制器 – Clafou 2012-04-02 16:41:16

回答

2

我Clafou同意,你怎麼設置你的應用程序可以胡來。

添加這個,看看它是否火災:

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    BOOL isPortraitOrientation; 

    if ((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){ 

     isPortraitOrientation = YES; 

    } else if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){ 

     isPortraitOrientation = NO; 

    } 
}