我有一个奇怪的,我希望有人能帮忙。我有一个应用程序,当我旋转到横向时,我隐藏了 NavigationBar ...
-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if( toInterfaceOrientation == UIInterfaceOrientationPortrait )
{
self.view = portraitView;
}
else if( toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft )
{
self.view = landscapeRightView;
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
这工作正常,导航栏消失。问题是,当我旋转回纵向时,我的导航栏重新出现,但在我的视图中间是垂直的,而不是在屏幕顶部水平!!!无论我将 NavBar 的重新外观放在哪里(旋转后,前半部分后),回到纵向视图时它总是处于错误的方向和位置。
这是我关于旋转回纵向的代码:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if( self.view == portraitView )
{
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
}
任何人都可以提供想法吗?这真让我抓狂!