こんにちは、コアプロットフレームワーク http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-applicationを使用してこのチュートリアルに従いました
プロジェクトはコンパイルされますが、ビューを試すとクラッシュします。UIView/ストーリーボードと関係があると思います。UIViewのクラスをCPTGraphHostingViewまで変更しましたが、それでも以下のエラーが発生します
キャッチされなかった例外'NSInvalidArgumentException'が原因でアプリを終了しています、理由:'-[UIView setHostedGraph:]:認識されないセレクターがインスタンス0x6b8afe0に送信されました'
何か案は ?以下のコード
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//CPTGraphHostingView *hostingView = (CPTGraphHostingView *) self.view;
//CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
//[self.view addSubview:hostingView];
hostingView.hostedGraph = graph;
graph.plotAreaFrame.plotArea.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
hostingView.hostedGraph = graph;
graph.paddingLeft = 20.0;
graph.paddingTop = 20.0;
graph.paddingRight = 20.0;
graph.paddingBottom = 20.0;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-6)
length:CPTDecimalFromFloat(12)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-5)
length:CPTDecimalFromFloat(30)];
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.lineColor = [CPTColor blackColor];
lineStyle.lineWidth = 2.0f;
axisSet.xAxis.majorIntervalLength = [[NSNumber numberWithInt:5] decimalValue];
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 5.0f;
axisSet.xAxis.majorTickLength = 7.0f;
axisSet.xAxis.labelOffset = 3.0f;
axisSet.yAxis.majorIntervalLength = [[NSNumber numberWithInt:5] decimalValue];
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 5.0f;
axisSet.yAxis.majorTickLength = 7.0f;
axisSet.yAxis.labelOffset = 3.0f;
CPTScatterPlot *xSquaredPlot = [[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame];
xSquaredPlot.identifier = @"X Squared Plot";
CPTMutableLineStyle *ls1 = [CPTMutableLineStyle lineStyle];
ls1.lineWidth = 1.0f;
ls1.lineColor = [CPTColor redColor];
xSquaredPlot.dataLineStyle = ls1;
xSquaredPlot.dataSource = self;
[graph addPlot:xSquaredPlot];
CPTPlotSymbol *greenCirclePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
greenCirclePlotSymbol.fill = [CPTFill fillWithColor:[CPTColor greenColor]];
greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0);
xSquaredPlot.plotSymbol = greenCirclePlotSymbol;
CPTScatterPlot *xInversePlot = [[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame];
xInversePlot.identifier = @"X Inverse Plot";
CPTMutableLineStyle *ls2 = [CPTMutableLineStyle lineStyle];
ls2.lineWidth = 1.0f;
ls2.lineColor = [CPTColor blueColor];
xInversePlot.dataLineStyle = ls2;
xInversePlot.dataSource = self;
[graph addPlot:xInversePlot];
}