私のアプリは、向きごとに非常に異なる UI 構造を持っています。
iPad の回転ライフサイクルのどの段階で削除し、向きの UI を追加して、最もスムーズな移行を確保する必要がありますか?
私のアプリは、向きごとに非常に異なる UI 構造を持っています。
iPad の回転ライフサイクルのどの段階で削除し、向きの UI を追加して、最もスムーズな移行を確保する必要がありますか?
オートローテーションを処理するときは、次の 4 つの主な方法に注意する必要があります。
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
さて、回転を処理する方法は、たとえば次のとおりです。
のすべてのフレームを調整しwillAnimateRotationToInterfaceOrientation
ます。
サブビューの追加/削除 (必要な場合) willRotateToInterfaceOrientation
;
でサブビューを復元します (必要な場合) didRotateFromInterfaceOrientation
。
より一般的には、アニメーション化可能なすべてのプロパティを変更しますwillAnimateRotationToInterfaceOrientation
。willRotateToInterfaceOrientation
/でアニメーション化できないすべての変更を行いますdidRotateFromInterfaceOrientation
。
これは、UIViewController リファレンスwillRotate
が/について述べていることdidRotate
です:
向きの変更中に不要な機能や問題を引き起こす可能性のある機能を一時的にオフにするには、 willRotateToInterfaceOrientation:duration: メソッドをオーバーライドして、そこで必要なアクションを実行します。その後、didRotateFromInterfaceOrientation: メソッドをオーバーライドし、向きの変更が完了したら、それを使用してこれらの機能を再度有効にすることができます。