質問

私は今コアプロットから始めて、いくつかの問題に陥りました。このページのチュートリアルに従いました。 http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application

このページの指示で完了しました。 http://code.google.com/p/core-plot/wiki/usingcoreplotinapplications (-all_loadなど)。

しかし、私にはまだいくつかの問題があります、私は次のエラーを取得します:

error: incompatible type for argument 1 of 'setMajorIntervalLength:'
error: request for member 'axisLabelOffset' in something not a structure or union
error: incompatible type for argument 1 of 'setMajorIntervalLength:'
error: request for member 'axisLabelOffset' in something not a structure or union
error: request for member 'bounds' in something not a structure or union
error: request for member 'defaultPlotSymbol' in something not a structure or union
error: request for member 'bounds' in something not a structure or union

私が間違っていることを知っている人は誰ですか?これは私のコードです:

- (void)viewDidLoad {
    [super viewDidLoad];

    graph = [[CPXYGraph alloc] initWithFrame: self.view.bounds];

    CPLayerHostingView *hostingView = (CPLayerHostingView *)self.view;
    hostingView.hostedLayer = graph;
    graph.paddingLeft = 20.0;
    graph.paddingTop = 20.0;
    graph.paddingRight = 20.0;
    graph.paddingBottom = 20.0;

    CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-6)
                                                   length:CPDecimalFromFloat(12)];
    plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5)
                                                   length:CPDecimalFromFloat(30)];

    CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;

    CPLineStyle *lineStyle = [CPLineStyle lineStyle];
    lineStyle.lineColor = [CPColor blackColor];
    lineStyle.lineWidth = 2.0f;

    axisSet.xAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
    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.axisLabelOffset = 3.0f;

    axisSet.yAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
    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.axisLabelOffset = 3.0f;

    CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc]
                                    initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
    xSquaredPlot.identifier = @"X Squared Plot";
    xSquaredPlot.dataLineStyle.lineWidth = 1.0f;
    xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
    xSquaredPlot.dataSource = self;
    [graph addPlot:xSquaredPlot];

    CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol];
    greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]];
    greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0);
    xSquaredPlot.defaultPlotSymbol = greenCirclePlotSymbol;  

    CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc]
                                    initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
    xInversePlot.identifier = @"X Inverse Plot";
    xInversePlot.dataLineStyle.lineWidth = 1.0f;
    xInversePlot.dataLineStyle.lineColor = [CPColor blueColor];
    xInversePlot.dataSource = self;
    [graph addPlot:xInversePlot];
}
役に立ちましたか?

解決

あなたが指摘している例は時代遅れであり、コアプロットフレームワークの現在のAPIと一致しなくなりました。 APIの変更に一致するように更新されたままにしていたため、フレームワークを使用して出荷するサンプルアプリケーションから始めることをお勧めします。

例えば axisLabelOffset に改名されました labelOffset, defaultPlotSymbol もう存在しません(設定します plotSymbol cpplotインスタンスのプロパティ)、プロットスペースにはもはやありません bounds プロパティ、そしてもはや使用する必要はありません -initWithFrame: CPPLOTインスタンスの場合。

繰り返しますが、フレームワークをテンプレートとして出荷するサンプルアプリケーションを使用して、そこから作業してください。まだ1.0リリースに到達していないため、フレームワークを安定させて強化するにつれてAPIが変更されます。

他のヒント

MajorIntervallengthが NSDecimal そして、あなたはaを返しています NSDecimalNumber. 。これらのエラーに対してこれが機能するかどうかを確認します。

axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];

他の人のために、あなたはどこかにヘッダーファイルを含めていますか?

set the header search and other link (Users..../framework & -ObjC respectively) 

私はあなたが絶対的な道を提供していると思います。 CorePlotドキュメントを実行すると、「ヘッダー検索パスフィールドで相対パスを提供する必要がある」と明確に言及していることがわかります。

相対的な道とは何かを学ぶために、」http://webdesign.about.com/od/beginingtutorials/a/aa040502a.htm"

以下のように、ターミナルコマンド「mdfind」を通してコアプロットのフルパスを取得します。

ターミナルタイプでは、mdfind -name coreplot

フルパス名が取得されます。

フルパスを取り、ヘッダー検索パスに挿入します

上記とともに... -objcを「othetrリンカーフラグ」に追加し、「ライブラリとリンクバイナリ」にQuartzフレームワークを追加します

それが動作します :)

私は次のことをしました:

1)#import "coreplot-cocoatouch.h" 2)uiviewcontrollerを.h vcファイルに追加しました3)cptestアプリからまったく同じコードを追加しました4)coreplot-cocoatouchフレームワークを私のプロジェクトに追加し、依存関係を設定しますターゲット設定、ヘッダー検索とその他のリンク(ユーザー..../Framework&-OBJC)のプロジェクト設定に設定し、Quartzcoreフレームワークを追加し、コンパイルすると次のことがわかります。

"coreplot-cocoatouch.h"そのようなファイルやディレクトリはありません。

ヘッダーファイルを見つけられない理由がわかりません...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top