2012-05-02 13 views
0

私はタブバー用の4つのコントローラを持っています。私は電話機を回転させると、コントローラの1つだけshouldAutorotateToInterfaceOrientationメソッドを呼び出すが、すべてのメソッドを呼び出す。回転時のナビゲーションバーとタブバー

コントローラの1つのみに対してshouldAutorotateToInterfaceOrientationをどのように呼び出すことができますか?

答えて

1

これらのメソッドを呼び出すことはありません。これらのメソッドは、UIViewControllerから継承するすべてのクラスに対して呼び出されているメソッドです。
とにかく呼び出されないようにする理由はありません。
あなたができることは、あなたのコントローラのいずれに対しても、これらの方法を無効にすることです。
このメソッドはbooleanを返します。trueを返した場合はビューを回転し、falseを返した場合はfalseを返します。

あなたはまた、YESを返すことを決定することができます/ NOの向きに基づいて、この場合、

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

1つの特定の向きをサポートするために、ビューは、新たな向きが縦向きである場合にのみ回転されていません。

0

JP Hribovsekありがとう、私はdevice'sの向きが変更されたときに私を通知するbeginGeneratingDeviceOrientationNotificationsを使用して、それを解決しました。例:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

[[NSNotificationCenter defaultCenter] addObserver: self 
             selector: @selector(deviceRotate:) 
              name: UIDeviceOrientationDidChangeNotification 
              object: nil]; 

-(void) deviceRotate: (NSNotification*) notification 
{ 
    UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; 

    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {  
     NSlog(@"Landscape");  
    } 
} 
関連する問題