我創建了一個UIViewController(基於How to switch views when rotating)在設備旋轉時在2個視圖之間切換。每個視圖對於特定的方向都是「專門的」。旋轉時移動的視圖
它使用UIDeviceOrientationDidChangeNotification通知切換視圖:
-(void) deviceDidRotate: (NSNotification *) aNotification{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
NSLog(@"Device rotated to %d!", orientation);
if ((orientation == UIDeviceOrientationPortrait) ||
(orientation == UIDeviceOrientationPortraitUpsideDown)) {
[self displayView:self.portraitViewController.view];
}else if ((orientation == UIDeviceOrientationLandscapeLeft) ||
(orientation == UIDeviceOrientationLandscapeRight)) {
[self displayView:self.landscapeViewController.view];
}
}
和排序的工作。當我旋轉到橫向,然後回到縱向時,出現問題。當回到肖像子視圖沒有在正確的地方顯示出來,特別是在UIPickerView:
首次肖像:
旋轉爲橫向:
返回至人像:
如果我重複輪換過程,情況會變得更糟。我究竟做錯了什麼?
的源代碼是在這裏:提前http://dl.dropbox.com/u/3978473/forums/Rotator.zip
謝謝!
我試着改變displayView:代碼,正如你所建議的那樣,但它不起作用。不管怎麼說,還是要謝謝你。 – cfischer 2011-03-27 13:50:05