我正在嘗試爲我的某個視圖處理viewcontroller上的設備方向更改。 這裏是我的代碼:UIDeviceOrientationDidChangeNotification只會觸發一次
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad");
// Tell the UIDevice to send notifications when the orientation changes
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
// tell the director that the orientation has changed
- (void) orientationChanged:(NSNotification *)notification
{
NSLog(@"orientationChanged");
}
當我第一次啓動應用程序時,orientationChanged選擇被調用,但在此之後,它不會再次呼籲無論多少我旋轉的iPad。有誰知道我可能做錯了什麼?當我在應用程序委託中放置類似的代碼時,它可以正常工作,但在這個特定的視圖控制器中,它並不適合。
shouldAutorotateToInterfaceOrientation用於自動旋轉視圖。我不希望視圖自動旋轉。我只想接收設備旋轉時間的通知。 – MrPrezident 2011-04-17 19:15:42