簡體   English   中英

iOS:旋轉iPad,什么時候可以改變視角?

[英]iOS: Rotating an iPad, what stage to change view?

我的應用程序針對每個方向的UI結構都非常不同。

我應該在iPad的旋轉生命周期的哪個階段刪除,然后添加方向的UI以確保最平穩的過渡?

處理自動旋轉時,您需要注意以下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中還didRotateFromInterfaceOrientation視圖(如果需要)。

一般來說,我將修改willAnimateRotationToInterfaceOrientation中可設置動畫的所有屬性; 雖然我會執行willRotateToInterfaceOrientation / didRotateFromInterfaceOrientation所有無法修改的修改。

這就是UIViewController參考關於willRotate / didRotate

要臨時關閉不需要的功能,否則可能會在方向更改過程中導致其他問題的功能,您可以覆蓋willRotateToInterfaceOrientation:duration:方法並在其中執行所需的操作。 然后,您可以覆蓋didRotateFromInterfaceOrientation:方法,並在方向更改完成后使用它重新啟用這些功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM