【发布时间】:2013-04-18 09:29:31
【问题描述】:
我在 iOS 应用程序中使用 CorePlot 来绘制散点图。首先,我在带有其他一些组件的视图中显示图表,但我还想让用户进入全屏模式以查看更多图表和平移/缩放。
当他们在全屏和非全屏模式之间切换时,我不想重绘图表,因为如果我可以重复使用视图,那似乎是在浪费时间。
在非全屏显示图表方面,我的工作正常,然后全屏显示,但是当我退出全屏模式时,我仍然希望用户在普通视图,但图表视图消失了。
这是我最初在第一个视图(非全屏)中设置图表视图的地方
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"non full screen graph view did load");
_graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTSlateTheme];
[_graph applyTheme:theme];
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.collapsesLayers = NO;
hostingView.hostedGraph = _graph;
//add plots etc. to graph - not shown
}
这很好用并绘制了我的图表。当我进入全屏模式时,这会显示全屏视图控制器:
-(void) goToFullScreen{
NSLog(@"full screen");
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[_rootNavController presentViewController:fullScreenVc animated:NO completion:nil];
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)fullScreenVc.graphView;
hostingView.collapsesLayers = NO;
hostingView.hostedGraph = _graph;
_graph.defaultPlotSpace.allowsUserInteraction = YES;
}
这也很好用,用户可以平移图表。
这就是问题所在 - 我正在关闭全屏视图控制器,并且不知何故也丢失了图形视图 - 当我回到原始视图控制器时,所有其他组件都在显示,但视图图应该是空的。
-(void) exitFullScreen{
NSLog(@"leaving full screen");
_graph.defaultPlotSpace.allowsUserInteraction = NO;
[_rootNavController dismissViewControllerAnimated:NO completion:nil];
}
任何想法我做错了什么,以至于我失去了图表视图?我已经检查过了,在exitFullScreen: 的末尾,_graph 不为空,它仍然包含我所有的情节。
谢谢, 莎拉
【问题讨论】:
标签: ios uiviewcontroller core-plot