我發現我的問題。
在viewWillAppear中我有:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(didChangeOrientation:) name: UIDeviceOrientationDidChangeNotification object:
[UIDevice currentDevice]];
這裏是通知處理程序:
- (void) didChangeOrientation: (id)object {
UIInterfaceOrientation interfaceOrientation = [[object object] orientation];
//DLog(@"val is %i", interfaceOrientation);
if (interfaceOrientation == UIDeviceOrientationLandscapeLeft || interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationPortrait) {
[self orientInterface:interfaceOrientation];
}
通過檢查方向是兩個景觀之一或兩個人像我忽略了UIDeviceOrientationFaceUp和UIDeviceOrientationFaceDown方向。通過這種方式將手機設置爲這兩種方向之一不會影響我的界面方向。
我的問題是,我沒有考慮faceUp和faceDown,並正在假設景觀的其他語句處理它們。
您能分享您用於回覆通知的代碼嗎? – nschum 2010-08-01 11:06:26