2009-12-11 22 views
2

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

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, je reçois 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 

Toute personne qui sait ce que je fais mal? Voici 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]; 
} 

Répondre

10

L'exemple que vous pointez est obsolète et ne correspond plus à l'API actuelle pour le framework de tracés principaux. Je suggère de commencer par les exemples d'applications livrés avec le framework (dans le répertoire examples), car nous avons gardé ces mises à jour pour correspondre à toutes les modifications de l'API.

Par exemple axisLabelOffset a été renommé labelOffset, defaultPlotSymbol n'existe plus (vous définissez la propriété plotSymbol sur une instance CPPlot) l'espace de la parcelle non, plus possède une propriété bounds, et vous n'avez plus besoin d'utiliser -initWithFrame: pour la CPPlot instances.

Encore une fois, utilisez simplement les exemples d'applications livrés avec le framework comme modèle, et travaillez à partir de là. Nous n'avons pas encore atteint la version 1.0, donc l'API changera à mesure que nous stabiliserons et améliorerons le cadre.

+0

Fera. Merci pour l'info. –

+0

Si vous avez besoin d'aide supplémentaire, n'hésitez pas à demander sur la liste de diffusion: http://groups.google.com/group/coreplot-discuss?hl=fr –

+0

Merci Brad, pour votre aide. –

3

vous obtenez l'erreur de type incompatible parce majorIntervalLength attend un NSDecimal et vous retournez un NSDecimalNumber. voir si cela fonctionne pour ces erreurs:

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

pour les autres, y compris les fichiers d'en-tête quelque part?

+0

Merci, cela a résolu 2 des erreurs. Les fichiers d'en-tête sont inclus inclus dans le fichier .h. #import "CorePlot-CocoaTouch.h" Observe/Paul –

+0

également en regardant le fichier d'en-tête CPAxis il ne semble pas y avoir un axe nLabelOffset seulement un labelOffset? –

-1

Ive fait ce qui suit:

1) ajouté #import "CorePlot-CocoaTouch.h" 2) a ajouté le: UIViewController au fichier vc .h 3) a ajouté le même code d'application CPTest 4) a ajouté le framework coreplot-cocoatouch à mon projet, définir la dépendance dans les paramètres cible, définir la recherche d'en-tête et d'autres liens (Users ..../framework & -ObjC respectivement) dans les paramètres du projet, ajouté le cadre QuartzCore et quand je compiler je reçois:

importer "CorePlot-CocoaTouch.h" AUCUN TEL DOSSIER OU RÉPERTOIRE ....

je ne comprends pas pourquoi il est de ne pas trouver les fichiers d'en-tête ...

+0

donc je suis allé manuellement aux paramètres de la cible et ajouté chemins de recherche d'en-tête de/Users/moi/core = plot/cadre +/framework/iPhoneOnly +/framework/Source et maintenant je reçois: A) Check Dependency = Sauter le fichier/Utilisateurs/moi/core-plot/framework/CorePlot-CocoaTouch.xcodeproj (type de fichier inattendu 'wrapper.pb-project' b) Lien = ".objc_class_name_CPTheme", référencé par ... (un tas entier) ... – mars

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

Je suppose que vous fournissez chemin absolu. Si vous passez par la documentation corePlot vous verrez qu'ils ont clairement mentionné: « Vous devez donner le chemin relatif au-tête chemin champ de recherche »

pour apprendre ce qui est un chemin relatif suivre, « http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm »

0

Acheter chemin de core-plot à travers la commande terminale "mdfind" comme ci-dessous.

Dans le type de terminal, mdfind -nom coreplot

va obtenir le nom de chemin complet.

Prenez le chemin complet et insérer dans les entêtes CHEMIN DE RECHERCHE

ainsi au-dessus ... ajouter -ObjC à « Drapeaux Othetr linker » et ajoutez cadre de travail Quartz dans « Lien binaire avec les bibliothèques »

Il sera TRAVAIL :)