2012-06-15 48 views
2

有什麼方法可以在設備方向動畫完成之前執行代碼?設備方向將改變而不是已經改變

現在,我將自己作爲一個觀察者UIDeviceOrientationDidChangeNotification

不過,我需要我的代碼來完成實際改變後發生不前。

回答

4

檢查文檔:)

響應視圖旋轉活動 -

willRotateToInterfaceOrientation:時間:

willAnimateRotationToInterfaceOrientation:時間:

didRotateFromInterfaceOrientation:

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

+0

我不使用一個UIViewController。這就是爲什麼我試圖給我們NSNotification中心 – Hackmodford

+0

哦,對不起。然後我建議這個答案。 http://stackoverflow.com/questions/1160620/how-do-i-detect-the-iphone-orientation-before-rotating –

+0

是的......我基本上做到了。並使用視圖setNeedsLayout。這樣我可以改變字段,它會更新顯示。 – Hackmodford

2

試圖改變它在這個方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
}