如何知道当前正在查看什么视图
我正在开发一个项目,在该项目中我呈现一个值表,当用户旋转屏幕景观时,会以图表形式显示详细信息。
到目前为止,一切正常,但有一个问题。例如,当我从 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 不要推送它?
谢谢分配!
i'm working on a project in which i present a table of values, and when the user rotates the screen landscape is shows the detail as a graph.
so far it all works, but there is a problem. When I go from LandscapeLeft strait to landscapeRight for example, it pushes the view again. Obviously I don't want this to happen.
Here is the code i used:
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];
}
My question is how can I know if the view is already viewed, so I can tell the NavigationController to not push it?
Thanks allot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论