3

私は2つのGUIと2つのコントローラーを持っています。1つはlandscapeguicontrollerと呼ばれ、2つ目はhighguicontrollerと呼ばれます。

今、一般的に私はhighguicontrollerを呼び出し、iPhoneを回転させるとそれが検出され、landscapeguicontrollerが表示されます: コード:

    landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:neu animated:YES];     
    [self dismissModalViewControllerAnimated:YES];

問題は、アニメーションが新しいウィンドウを iPhone の向こう側からウィンドウに押し上げることです。

Landscapeguicontroller で、次の行に追加しました。

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

highguicontroller に戻りたいときは、次のように呼び出します。

[self dismissModalViewControllerAnimated:YES];

すべてが機能しますが、2番目のアニメーションで正しい「回転アニメーション」が表示されます。何か提案はありますか?

簡単な問題の説明: 1. 高いところから風景へのアニメーションでは、風景がウィンドウに押し込まれますが、2. 風景から高いところへのアニメーションでは、回転が実際の回転のように見えます...

1.アニメーションを 2.アニメーションのようにしたい

宜しくお願いします

4

2 に答える 2

3

「問題は、アニメーションが新しいウィンドウをiphoneの向こう側からウィンドウに押し上げることです。」を回避するには、ViewControllerのmodalTransitionStyleプロパティを次のいずれかに設定してみてください。typedefenum{UIModalTransitionStyleCoverVertical = 0、UIModalTransitionStyleFlipHorizo​​ntal、UIModalTransitionStyleCrossDissolve、} UIModalTransitionStyle;

また、アニメーション化された回転を避けたい場合は、shouldRotate ...メソッドを設定して他の方向を許可しないようにしますが、デバイスが物理的に方向を変更したときに通知を受信し、適切な方向にあるときにモーダルビューコントローラーを表示するように設定します。それ。この例については、Appleの「AlternateViews」サンプルコードを参照してください。

通知はデバイスの物理的な向きを反映しており、インターフェイスの変更が許可されているかどうかに関係なく通知を受け取ることができます。(UIApplicationsのstatusBarOrientationプロパティを見て、UIの方向を確認できます)。

于 2009-11-30T00:23:06.153 に答える
1

シーケンスを次のようにしたいようです:

  1. デバイスを縦向きから横向きに物理的に回転させます
  2. 縦向きビュー ( highguicontroller) を横向きにアニメーション化する
  3. landscapeguicontroller画面の新しい「下」から横向きビュー ( ) を押し上げます。

そうであれば、highguicontroller実装に次のようなものが必要です。

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

これでステップ 2 が処理されます (どちらかの方向に縦向きビューが横向きビューに回転します)。

次に、次のようなものが必要になります。

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  if(fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
    [self presentModalViewController:landscapeguicontroller animated:YES];
  }
  else {
    [self dismissModalViewControllerAnimated:YES];
  }
}

回転アニメーションが完了すると横向きのビューが表示され、デバイスが回転して縦向きに戻った後に閉じる必要があります。

それが役立つことを願っています!

于 2009-10-17T07:56:35.580 に答える