我有一个散点图类:
@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 = 图;
我很好地实现了 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];
但是我看不到我的图表:(
我错过了什么?
最佳答案
好的,我做到了。我要添加到 View (页面)中的元素对象应该是 CPTGraphHostingView。 一切都会好起来的。
[(UIView *)page performSelectorOnMainThread:@selector(addSubview:) withObject:firstScatterPlot waitUntilDone:YES];
关于ios - 我添加了 ScatterPlot View 但我无法在页面上看到它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14890583/