[英]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
現在,我處理旋轉的方式為:
調整willAnimateRotationToInterfaceOrientation
所有幀;
在willRotateToInterfaceOrientation
添加/刪除子視圖(如果需要);
在didRotateFromInterfaceOrientation
中還didRotateFromInterfaceOrientation
視圖(如果需要)。
一般來說,我將修改willAnimateRotationToInterfaceOrientation
中可設置動畫的所有屬性; 雖然我會執行willRotateToInterfaceOrientation
/ didRotateFromInterfaceOrientation
所有無法修改的修改。
這就是UIViewController參考關於willRotate
/ didRotate
:
要臨時關閉不需要的功能,否則可能會在方向更改過程中導致其他問題的功能,您可以覆蓋willRotateToInterfaceOrientation:duration:方法並在其中執行所需的操作。 然后,您可以覆蓋didRotateFromInterfaceOrientation:方法,並在方向更改完成后使用它重新啟用這些功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.