2009-06-10 26 views
1

我正在旋轉類似於iTunes應用程序的視圖。在肖像是一個桌面和風景是照片查看器。當navigationBarHidden = NO時,如何修復「空白」區域

當我從風景回到縱向時,我嘗試恢復導航欄,但是卻得到了失真的tableview,沒有導航欄。

這是我做的:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
          duration:(NSTimeInterval)duration { 
BOOL restoreNav = NO; 

if ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || 
    (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) { 
    [self inPortrait]; 
    restoreNav = YES; 
} else { 
    [self inLandscape]; 
} 

if (self.landscape) 
{ 
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait) 
    { 
     self.view = self.portrait; 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) 
    { 
     self.view = self.landscape; 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
    { 
     self.view = self.portrait; 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
     self.view = self.landscape; 
    }  
    [[self.navigationController view] setFrame: [[UIScreen mainScreen] bounds]]; 
} else { 
    self.navigationController.navigationBarHidden = NO; 
} 

[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 
+0

問題不清楚嗎? – mamcx 2009-06-11 16:01:08

回答

1

我發現了一個半修復該http://www.iphonedevsdk.com/forum/iphone-sdk-development/3262-horrible-drawing-after-hiding-navigationbar.html

這是相關代碼:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
//total hack - to fix the bug where the screen layout is shagged if the device orientation 
//is changed when the navigation is hidden 

if ([self.navigationController isNavigationBarHidden]) 
{ 
    [self.navigationController setNavigationBarHidden:NO animated:NO]; 
    [self.navigationController setNavigationBarHidden:TRUE animated:NO]; 
} 

}

然而,如果顯示導航欄,又是一團糟。