2011-07-11 9 views
0

4つのビューモード(ポートレート上下左右に使用可能)のiPadアプリケーションがあります。しかし、ある時点で、私はただの風景モードで見たいと思うビューを持っています。だから私は風景専用ビューを表示するためのアクションをトリガーすることのUIViewControllerで次の操作を行います。これは正常に動作しますので、表示さiPad:向きに応じて別の画面を表示する方法(風景/肖像画)

- (void) showProperty:(Property *) property { 
    if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft || [self interfaceOrientation] == UIInterfaceOrientationLandscapeRight) { 
     PropertyViewController *propertyView = [[PropertyViewController alloc] initWithNibName:@"PropertyViewController" bundle:[NSBundle mainBundle]]; 
     propertyView.property  = property; 
     [self.navigationController pushViewController:propertyView animated:YES]; 
     [propertyView release]; 
     propertyView = nil; 
    } 
    else { 
     RotateDeviceViewController *rotateView = [[RotateDeviceViewController alloc] initWithNibName:@"TabRotate" bundle: [NSBundle mainBundle]]; 
     rotateView.property = property; 
     [self.navigationController pushViewController:rotateView animated:YES]; 
     [rotateView release]; 
     rotateView = nil; 
    } 
} 

をいずれかの目的の画面(PropertyViewController)のiPadは、ランドスケープモードに保持されているときに、そうでなければ、RotateDeviceViewControllerを表示します。これは、デバイスを回転させて画面を正しく表示するはずのメッセージをユーザーに表示します。

ユーザがデバイスを横長モードにして回転させると、正しいビュー(PropertyViewController)が表示されます。そして、これはまあまあです!

問題はこのRotateDeviceViewControllerにかかわらず発生し...そこで私は、次のしている:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
     [self showProperty]; 
    return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
} 

- (void) showProperty { 
    PropertyViewController *propertyView = [[PropertyViewController alloc] initWithNibName:@"PropertyViewController" bundle:[NSBundle mainBundle]]; 
    propertyView.property  = property; 
    [self.navigationController pushViewController:propertyView animated:YES]; 
    [propertyView release]; 
} 

だから、できるだけ早く私は、デバイスを回転させると風景モードに(RotateDeviceViewControllerを見たときの)Iが示しますユーザーPropertyViewController。これは機能します...しかし、PropertyViewControllerが表示されたら、私のレイアウトは90度回転しています。だから、基本的には、肖像モードの代わりに、(実際には、デバイスを保持している方法です)風景モードを使用してコンテンツを表示...

私は、これは理にかなっていると、誰かがこれを引き起こしているものを見せてことを願って。

スクリーンショットそれをより明確にする:

答えて

1

この時点で

- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation 

あなたがサポートしてどのような姿勢ビューコントローラを言っています。デバイスは実際にまだ回転していないので、ビューコントローラintefaceOrientationのプロパティはまだportraitになります。したがって、スタックにプッシュされると、デバイスはportraitと考えられます。

pseudo code 
shouldAutoRotate... // at this point self.interfaceOrientation == portrait 
        // you push your controller here so it loads when the property is 

私はこれがうまくいくかどうかわからないんだけど、私はあなたがプッシュすることができます見ることができる最も早い

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
+0

であるinterfaceOrientation(したがってself.interfaceOrientationが)ように読み取り専用の変数です動作しません。 ** didRotateFromInterfaceOrientation **メソッドを使用すると機能しました。私はこの出来事を知らなかった。ありがとう! – Jules

+0

これは読み取り専用の属性だが、これはビューコントローラが内部的に使用するものだと仮定しているため、コントローラをプッシュする最適なタイミングを選択できるように、設定されていることを知ることが重要です。 –

+0

willrotateto ...州の位置を変えたいなら、/ xとyを邪魔しないで –

関連する問題