Navigation 如何知道当前查看的视图

Navigation 如何知道当前查看的视图,navigation,rotation,Navigation,Rotation,我正在做一个项目,在这个项目中,我展示了一个值表,当用户旋转屏幕时,它会以图形的形式显示细节 到目前为止,一切正常,但有一个问题。例如,当我从景观左海峡到景观右海峡时,它会再次推动视图。显然,我不想发生这种事 以下是我使用的代码: UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; if (orientation == UIDeviceOrientationLandscapeLeft) {

我正在做一个项目,在这个项目中,我展示了一个值表,当用户旋转屏幕时,它会以图形的形式显示细节

到目前为止,一切正常,但有一个问题。例如,当我从景观左海峡到景观右海峡时,它会再次推动视图。显然,我不想发生这种事

以下是我使用的代码:

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation == UIDeviceOrientationLandscapeLeft)
{
    NSLog(@"Landscape Left!");
    GraphViewController *gvc = [[GraphViewController alloc] initWithNibName:@"GraphViewController" bundle:nil];

        [self.navigationController pushViewController:gvc animated:YES];
        strg.orient = [[NSNumber alloc] initWithInt:1];
}
if (orientation == UIDeviceOrientationLandscapeRight)
{
    NSLog(@"Landscape Right!");
    GraphViewController *gvc = [[GraphViewController alloc] initWithNibName:@"GraphViewController" bundle:nil];

        [self.navigationController pushViewController:gvc animated:YES];
        strg.orient = [[NSNumber alloc] initWithInt:2];
}
if (orientation == UIDeviceOrientationPortrait)
{
    NSLog(@"Portrate!");

    [self.navigationController popViewControllerAnimated:YES];
}   
我的问题是如何知道视图是否已被查看,以便告诉NavigationController不要推送它


谢谢你

这是什么语言?您尚未指定一个标记来指示该操作。