Question

J'ai commencé avec Core-Plot maintenant et j'ai eu quelques problèmes. J'ai suivi le tutoriel de cette page: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application

et complété avec les instructions de cette page: http://code.google.com/p/core-plot/wiki/usingcoreplotinapplications (comme -all_load).

Mais j'ai encore quelques problèmes, j'obtiens les erreurs suivantes:

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

Quelqu'un qui sait ce que je fais de mal? Ceci est mon code:

- (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];
}
Était-ce utile?

La solution

L'exemple que vous pointez est obsolète et ne correspond plus à l'API actuel pour le cadre de tracé de base. Je suggère de commencer par les exemples d'applications qui expédient avec le cadre (dans le répertoire des exemples), car nous les avons mis à jour pour correspondre à toutes les modifications de l'API.

Par exemple axisLabelOffset a été renommé labelOffset, defaultPlotSymbol n'existe plus (vous définissez le plotSymbol propriété sur une instance CPPLOT), l'espace de l'intrigue n'a plus de bounds propriété, et vous n'avez plus besoin d'utiliser -initWithFrame: Pour les instances CPPLOT.

Encore une fois, utilisez simplement les exemples d'applications qui expédient avec le framework comme modèle et fonctionnent à partir de là. Nous n'avons pas encore atteint de version 1.0, donc l'API changera à mesure que nous stabilisons et améliorons le cadre.

Autres conseils

Vous obtenez l'erreur de type incompatible car MajorInterVallEngth s'attend à un NSDecimal Et vous retournez un NSDecimalNumber. Voyez si cela fonctionne pour ces erreurs:

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

Pour les autres, incluez-vous les fichiers d'en-tête quelque part?

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

Je suppose que vous fournissez un chemin absolu. Si vous passez par la documentation CorePlot, vous verrez qu'ils ont clairement mentionné "vous devriez donner un chemin relatif au champ de chemin de recherche d'en-tête"

Pour savoir ce qui est un chemin relatif suivre, "http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm"

Obtenez le chemin complet de la commande du borne de noyau à la borne "mdfind" comme ci-dessous.

Dans le type de terminal, mdfind -name coreplot

obtiendra le nom complet du chemin.

Prendre le chemin complet et insérer dans le chemin de recherche des en-têtes

Avec ci-dessus ... Ajouter -OBJC à "Othetr Linker Flags" et ajouter le cadre de quartz fonctionne dans "Link Binary With Libraries"

Ça va marcher :)

J'ai fait ce qui suit:

1) Ajout de #Import "Coreplot-coocoatouch.h" 2) Ajout du: uiViewController au fichier .h VC 3) Ajout du même code de CPTest App 4) Paramètres cibles, définissez la recherche d'en-tête et d'autres liens (utilisateurs .... / framework & -objc respectivement) dans les paramètres du projet, ajoutant le framework Quartzcore et lorsque j'obtiens, j'obtiens:

Importez "Coreplot-cooatouch.h" Aucun fichier ou répertoire de ce type ....

Je ne comprends pas pourquoi il ne trouve pas les fichiers d'en-tête ...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top