如何知道当前查看的视图

时间:2011-11-10 11:25:45

标签: navigation rotation

我正在开展一个项目,其中我提供了一个值表,当用户旋转时,屏幕上的景观会以图形的形式显示细节。

到目前为止一切正常,但有一个问题。例如,当我从LandscapeLeft海峡前往landscapeRight时,它会再次推动视图。显然我不希望这种情况发生。

以下是我使用的代码:

    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不要推它?

感谢分配!

0 个答案:

没有答案