我正在嘗試檢測任何設備方向更改,以便我可以更新視圖。查看輪播通知:爲什麼didRotateFromInterfaceOrientation:沒有被調用?
我想要的方向是縱向還是橫向,以更新的觀點,讓我實現了這個方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
我知道,如果我想更新的意見正確顯示當前方位,我需要實現以下一些方法:現在
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– didAnimateFirstHalfOfRotationToInterfaceOrientation:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
,問題是,我不明白爲什麼這些方法都沒有,當我旋轉模擬器會被解僱。
我試着以及這段代碼:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
但仍然一無所獲。所以我想知道,模擬器是否會觸發輪轉通知? 如果是,我做錯了什麼?
你在哪裏實現了這個方法? – 2011-05-24 13:19:21
是模擬器發送旋轉通知。 – Ishu 2011-05-24 13:20:55
@Ishu:感謝您的信息; @Deepak:如果你指的是方法didRotateFromInterfaceOrientation,我在我的視圖控制器的.m文件中實現了它;如果您正在討論[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications],我在視圖控制器的viewDidLoad中執行了此操作。 – singingAtom 2011-05-24 13:31:08