很难让 CorePlot
在我的项目中工作,但现在一切都可以运行。除了空白的白色屏幕,我什么都看不到。
使用下面的代码,我不应该至少是一个空白图表吗?
self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease];
layerHostingView.hostedGraph = graph;
[self addSubview:layerHostingView];
感谢帮助我解决这个问题。
仅供引用,这不是我第一次使用 coreplot
进行测试。几天来我一直在研究这个问题,从那以后我尝试了所有我能得到的完整例子。我认为从基础开始重新开始是个好主意。
最佳答案
老实说,我不知道发生了什么变化,但我看到了一个包含这段代码的裸图。
.h
#import <UIKit/UIKit.h>
#import "CorePlot-CocoaTouch.h"
@interface RaceDetailView : UIView <CPTPlotSpaceDelegate, CPTPlotDataSource, CPTScatterPlotDelegate>
@end
.m
#import "RaceDetailView.h"
@implementation RaceDetailView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
CGRect f = self.frame;
CPTXYGraph *graph = [[[CPTXYGraph alloc] initWithFrame:f] autorelease];
CPTGraphHostingView *layerHostingView = [[CPTGraphHostingView alloc] initWithFrame:f];
layerHostingView.hostedGraph = graph;
[graph applyTheme:[CPTTheme themeNamed:kCPTDarkGradientTheme]];
[self addSubview:layerHostingView];
}
return self;
}
@end
关于ios核心图设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9297194/