سؤال

بدأت مع مؤامرة الأساسية الآن وجاءت إلى بعض المشاكل. تابعت البرنامج التعليمي من هذه الصفحة: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-ipplication.

وإكمال مع التعليمات من هذه الصفحة: http://code.google.com/p/core-plot/wiki/usingcoreplotinapplications. (مثل -L_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 أثناء استقراره وتعزيزه.

نصائح أخرى

أنت تحصل على خطأ من النوع غير المتوافق لأن الطول الرئيسي يتوقع NSDecimal وأنت تعود NSDecimalNumber. وبعد معرفة ما إذا كان هذا يعمل لتلك الأخطاء:

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

بالنسبة للآخرين هل أنت بما في ذلك ملفات الرأس في مكان ما؟

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

أعتقد أنك تقدم المسار المطلق. إذا ذهبت من خلال وثائق COMSPLOT، فسوف ترى أنهم قد ذكروا بوضوح "يجب عليك إعطاء المسار النسبي في حقل مسار البحث عن الرأس"

لمعرفة ما هو المسار النسبي، "http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm."

احصل على مسار كامل من Core-Plot Thru Terminal Command "MDFIND" على النحو التالي.

في النوع المحطة، MDFIND -NAME COXPLOT

سوف تحصل على اسم المسار الكامل.

خذ المسار الكامل وأدخل في مسار البحث عن رؤوس

جنبا إلى جنب مع أعلاه ... إضافة -OBJC إلى "أعلام روابط OTHETRETR" وإضافة إطار الكوارتز العمل في "Link Binary مع المكتبات"

سوف تعمل :)

لقد فعلت ما يلي:

1) أضيفت #mport "coreplot-cocoatouch.h" 2) أضيف: uiviewcontroller إلى ملف .h VC 3) إضافة نفس الكود نفسه من CPTEST APP 4) إضافة إطار CorePlot-Cocatouch إلى مشروعي، تعيين التبعية في الإعدادات المستهدفة، اضبط البحث عن الرأس وغيرها من الرابط (المستخدمين .... / Framework & -objc على التوالي) في إعدادات المشروع، وأضاف إطار كوارتزكور وعندما تجميع أحصل على:

استيراد "Coreplot-cocoatouch.h" لا يوجد مثل هذا الملف أو الدليل ....

أنا لا أفهم لماذا لا يجد ملفات الرأس ...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top