0

私のアプリは、向きごとに非常に異なる UI 構造を持っています。

iPad の回転ライフサイクルのどの段階で削除し、向きの UI を追加して、最もスムーズな移行を確保する必要がありますか?

4

1 に答える 1

6

オートローテーションを処理するときは、次の 4 つの主な方法に注意する必要があります。

shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation                                   duration:(NSTimeInterval)duration

willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                            duration:(NSTimeInterval)duration

didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

さて、回転を処理する方法は、たとえば次のとおりです。

  1. のすべてのフレームを調整しwillAnimateRotationToInterfaceOrientationます。

  2. サブビューの追加/削除 (必要な場合) willRotateToInterfaceOrientation;

  3. でサブビューを復元します (必要な場合) didRotateFromInterfaceOrientation

より一般的には、アニメーション化可能なすべてのプロパティを変更しますwillAnimateRotationToInterfaceOrientationwillRotateToInterfaceOrientation/でアニメーション化できないすべての変更を行いますdidRotateFromInterfaceOrientation

これは、UIViewController リファレンスwillRotateが/について述べていることdidRotateです:

向きの変更中に不要な機能や問題を引き起こす可能性のある機能を一時的にオフにするには、 willRotateToInterfaceOrientation:duration: メソッドをオーバーライドして、そこで必要なアクションを実行します。その後、didRotateFromInterfaceOrientation: メソッドをオーバーライドし、向きの変更が完了したら、それを使用してこれらの機能を再度有効にすることができます。

于 2012-02-11T18:28:33.797 に答える