CorePlot 문제
-
19-09-2019 - |
문제
나는 지금 Core-Plot으로 시작하여 몇 가지 문제에 도달했습니다. 이 페이지에서 튜토리얼을 따랐습니다. 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/beginningtutorials/a/aa040502a.htm"
아래와 같이 터미널 명령 "mdfind"를 통해 코어 플롯의 전체 경로를 가져옵니다.
터미널 유형에서 mdfind -name coreplot
전체 경로 이름을 얻습니다.
전체 경로를 가져 와서 헤더 검색 경로에 삽입하십시오
위와 함께 ... "Othetr 링커 플래그"에 -objc를 추가하고 "라이브러리 링크 바이너리 링크"에서 석영 프레임 작업을 추가하십시오.
작동합니다 :)
다음을 수행했습니다.
1) #import "CorePlot-Cocoatouch.h"2) 추가 : UIViewController가 .h VC 파일에 UIViewController를 추가했습니다. 대상 설정, 헤더 검색 및 기타 링크 (각각 .../프레임 워크 & -objc)를 프로젝트 설정에서 설정하고 쿼츠 코어 프레임 워크를 추가하고 컴파일 할 때 다음을 얻습니다.
"CorePlot-Cocoatouch.h"가져 오기 "그러한 파일이나 디렉토리가 없습니다 ....
헤더 파일을 찾지 못하는 이유를 이해하지 못합니다 ...