Pregunta

Comencé con Core-Plot ahora y llegué a algunos problemas. Seguí el tutorial desde esta página: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application

y completado con las instrucciones de esta página: http://code.google.com/p/core-plot/wiki/usingcoreplotinapplications (como -LL_LOAD).

Pero todavía tengo algunos problemas, obtengo los siguientes errores:

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

¿Alguien que sepa lo que estoy haciendo mal? Este es mi código:

- (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];
}
¿Fue útil?

Solución

El ejemplo al que señala está desactualizado y ya no coincide con la API actual para el marco de la trama central. Sugeriría comenzar con las aplicaciones de muestra que se envían con el marco (en el directorio de ejemplos), ya que hemos mantenido las actualizadas para que coincidan con cualquier cambio de API.

Por ejemplo axisLabelOffset ha sido renombrado para labelOffset, defaultPlotSymbol ya no existe (establece el plotSymbol propiedad en una instancia de CPPLOT), el espacio de la parcela ya no tiene un bounds propiedad, y ya no necesita usar -initWithFrame: Para las instancias de CPPLOT.

Nuevamente, solo use las aplicaciones de muestra que se envían con el marco como plantilla y trabaje desde allí. Todavía no hemos llegado a una versión 1.0, por lo que la API cambiará a medida que estabilicemos y mejoremos el marco.

Otros consejos

Obtiene el error de tipo incompatible porque MajorIntervallength espera un NSDecimal Y estás devolviendo un NSDecimalNumber. Vea si esto funciona para esos errores:

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

Para los demás, ¿incluye los archivos de encabezado en algún lugar?

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

Supongo que estás proporcionando un camino absoluto. Si pasa por la documentación de CorePlot, verá que han mencionado claramente "Debe dar una ruta relativa en el campo de la ruta de búsqueda del encabezado"

Para aprender qué sigue un camino relativo ",http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm"

Obtenga la ruta completa del comando de terminal "mdfind". como se muestra a continuación.

En tipo terminal, mdfind -name coreplot

obtendrá el nombre completo de la ruta.

Tome el camino completo e inserte en la ruta de búsqueda de encabezados

Junto con arriba ... Agregar -objc a "othetr enlazador de enlazador" y agregue el trabajo del marco de cuarzo en "Link binary con bibliotecas"

Funcionará :)

He hecho lo siguiente:

1) Se agregó #Import "CorePlot-CoCocouch.h" 2) Se agregó el: UIViewController al archivo .h VC 3) Se agregó exactamente el mismo código de la aplicación CPTEST 4) Se agregó el marco CorePlot-CoCocouch a mi proyecto, establece la dependencia en Configuración de destino, configure la búsqueda del encabezado y otros enlaces (usuarios ..../Framework & -objc respectivamente) en la configuración del proyecto, agregó el marco QuartzCore y cuando compilo obtengo:

Importar "Coreplot-COCOOCOUCH.H" No hay dicho archivo o directorio ....

No entiendo por qué no está encontrando los archivos de encabezado ...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top