Domanda

Ho iniziato con core-plot ora e sono venuto ad alcuni problemi. Ho seguito il tutorial da questa pagina: http: // www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application

e completato con le istruzioni di questa pagina: http: // codice. google.com/p/core-plot/wiki/UsingCorePlotInApplications (come -all_load).

Ma ho ancora qualche problema, ottengo i seguenti errori:

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

Chiunque sa che cosa sto facendo male? Questo è il mio codice:

- (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];
}
È stato utile?

Soluzione

L'esempio che stai indicando non è aggiornato e non corrisponde più l'API corrente per il quadro Nucleo Plot. Io suggerirei di iniziare con le applicazioni di esempio forniti con il quadro (nella directory di esempi), come abbiamo mantenuto quelli aggiornati in base alle modifiche API.

Per esempio axisLabelOffset è stato rinominato labelOffset, defaultPlotSymbol non esiste più (si imposta la proprietà plotSymbol su un'istanza CPPlot), lo spazio di trama non ha una proprietà bounds, e non è più necessario utilizzare -initWithFrame: per le istanze CPPlot .

Anche in questo caso, basta usare le applicazioni di esempio forniti con il quadro come modello, e lavorare da lì. Non abbiamo ancora raggiunto un rilascio 1.0, l'API cambieremo come abbiamo stabilizzare e migliorare il quadro.

Altri suggerimenti

si stanno ottenendo l'errore di tipo incompatibile perché majorIntervalLength si aspetta un NSDecimal e si restituisce un NSDecimalNumber. vedere se questo funziona per quegli errori:

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

per gli altri sono voi compresi i file di intestazione da qualche parte?

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

Credo che si stanno fornendo Percorso assoluto. Se si passa attraverso la documentazione corePlot vedrete che essi hanno chiaramente detto "Si dovrebbe dare percorso relativo al percorso di ricerca di intestazione campo"

per imparare ciò che è un percorso relativo seguire, " http://webdesign.about.com/od/beginningtutorials/a/aa040502a htm "

ottenere pieno percorso di core-plot attraverso comando terminale "mdfind" come qui sotto.

Nel tipo di terminale, mdfind -name coreplot

otterrà percorso completo.

Prendere il percorso completo e inserire nelle intestazioni PERCORSO DI RICERCA

con sopra ... aggiungi -Objc a "Othetr Linker Flags" e aggiungere cornice di lavoro al quarzo in "Link binari con le librerie"

Si lavorerà:)

Ive fatto il seguente:

1) aggiunto #import "CorePlot-CocoaTouch.h" 2) aggiunto il: UIViewController al file .h vc 3) ha aggiunto lo stesso codice esatto da CPTest app 4) ha aggiunto il framework Cocoa Touch-coreplot al mio progetto, impostare la dipendenza nelle impostazioni di destinazione, impostare la ricerca intestazione e altro collegamento (Utenti .... / quadro e -ObjC rispettivamente) nelle impostazioni di progetto, ha aggiunto il quadro QuartzCore e quando ho compilazione ottengo:

Importa "CorePlot-CocoaTouch.h" No such file or directory ....

Non capisco perché la sua non trovare i file di intestazione ...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top