2009-06-22 37 views

回答

8

您的視圖控制器將被髮送:

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

實現它做一些事情的時候,手機被旋轉

轉動完成後,您將獲得:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

這裏它在文檔中(請參閱處理視圖旋轉)

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

1

當您旋轉設備時,您的視圖控制器會收到一個didRotateFromInterfaceOrientation: 消息,其中舊方向。您可以檢查interfaceOrientation屬性以查看當前的旋轉,並相應地執行操作。

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
1

您需要捕獲在ViewController旋轉之前發送的事件。即:

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

和崗位輪換

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
0

方法名是正確的......但他們從來沒有被調用。 會導致什麼?

1

你應該先實現實例方法「shouldAutorotateToInterfaceOrientation」並返回YES。 然後這兩個方法將被調用。