问题描述
||
我有一个怪异的东西,希望有人能帮忙。
我有一个应用程序,当我旋转到风景时,我隐藏了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消失。问题是,当我旋转回纵向时,我的导航栏会重新出现,但是在视图中间是垂直的,而不是在屏幕顶部的水平!!!无论我将NavBar的外观放在何处(旋转后,上半部之后),返回肖像视图时,它始终处于错误的方向和位置。
这是我旋转回纵向的代码:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if( self.view == portraitView )
{
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
}
谁能提供想法?这真让我抓狂!
解决方法
同时检查
如果(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
否则if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
}