我有一个散点图类,如:
@interface myCPTScatterPlot : UIView <CPTPlotDataSource , CPTScatterPlotDelegate , CPTScatterPlotDataSource>
@property (nonatomic, assign) CPTGraphHostingView *hostView;
-(void) initAll;
-(void) configureHost;
-(void) configureGraph;
-(void) configurePlots;
-(void) configureAxes;
@end
我实现了所有配置功能。我创建了一个图表并将其添加到主机中: self.hostView.hostedGraph = graph;
我很好地实现了myCPTScatterPlot.mm文件。
我在myCPTScatterPlot.mm文件中有一个initWithframe函数,如:
-(id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
hostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc] initWithFrame:frame];
}
return self;
}
最后,我有一个pageView.mm文件,我将所有页面对象添加到我的page.view中
[(UIView *)page performSelectorOnMainThread:@selector(addSubview:) withObject:firstScatterPlot waitUntilDone:YES];
但是我看不到我的图表:(
我错过了什么?
答案 0 :(得分:1)
好的,我做到了。我要添加到视图(页面)的元素对象应该是CPTGraphHostingView。 比一切都好。
[(UIView *)page performSelectorOnMainThread:@selector(addSubview:) withObject:firstScatterPlot waitUntilDone:YES];