-(void)didRotateFromInterfaceOrientation:
...適應已經旋轉到橫向視圖。
不過,我不知道什麼時候該視圖需要旋轉回縱向使用哪種方法。
-(void)didRotateFromInterfaceOrientation:
...適應已經旋轉到橫向視圖。
不過,我不知道什麼時候該視圖需要旋轉回縱向使用哪種方法。
您可以使用同樣的方法,但包括一個測試,看看有什麼方向變化了。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
switch fromInterfaceOrientation {
case UIInterfaceOrientationPortrait {
//... handle roation from portrait
break;
}
case UIInterfaceOrientationLandscapeLeft {
//... handle roation LandscapeLeft
break;
}
//.. and so on
}
}
然而,在配置視圖新的方向應該在以「將」開始旋轉方法之一來完成。上述方法告訴視圖控制器是什麼以前方向了。它不會發送當前的方向是或將會是什麼。 「will」方法允許您在新方向完成之前調整視圖。
我用(無效)didRotateFromInterfaceOrientation啓用旋轉時以適應視...
你缺少一個冒號。該方法需要一個參數,所以它是didRotateFromInterfaceOrientation:
。
didRotateFromInterfaceOrientation
是另一種有效的選擇,但它的名字完全不同的(也可能不存在,從來沒有所謂的)方法。
...但是,至於什麼方法或如何檢測iPhone回到垂直位置,以便readapt視圖?
就在我可以從the documentation中弄出來的時候,同樣的方法可以完成這兩個任務。該方法的論點是舊方向,而self.interfaceRotation
是新的方向。
因此,請檢查其中一個值(如果我是iPhone程序員,則使用self.interfaceRotation
)以查看您現在處於哪個方位,並相應地更新您的視圖。
大,工作,謝謝! – Ruthy 2010-04-13 12:24:25