改变方向时在导航控制器上发出



我有两个视图控制器,其中我使用导航控制器从一个视图导航到另一个.....在我的第一个视图控制器中,我在- (void)viewDidLoad

中以这种方式检查方向
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
//Do this task
}
else
{
//Do this task
}

当我试图从第二个到第一个视图控制器导航…我使用这个代码来导航

-(IBAction)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

问题来了……以上方向条件未勾选。当我试图从第二个视图控制器导航到第一个视图控制器......我不知道我落在哪里了....我是否被任何逻辑卡住了,或者我想改变我的代码???????

调用这个方法

    -(void) viewWillAppear:(BOOL)animated{

        [self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0]; 
    }

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
    {
    set frame here........  
    }
    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight )
    {
    set frame here........          
    }

}

相关内容

最新更新