2011-02-18 1 views
1

j'obtiens l'erreur ci-dessous lorsque je tente de compiler le code ci-dessous:Erreur: "- [UIView setHostedGraph:]: sélecteur non reconnu" lors de l'exécution du complot de base dans l'iPhone app

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x6768c10'

code:

UIView *ChartView; 

    ChartView = [[UIView alloc] init]; 
    graph = [[CPXYGraph alloc] initWithFrame: ChartView.bounds]; 

CPGraphHostingView *hostingView = (CPGraphHostingView *)ChartView; 
hostingView.hostedGraph = graph; 

Qu'est-ce qui pourrait ne pas fonctionner?

Répondre

7

Vous castez une instance UIView (qui ne pas répondre à -setHostedGraph:) à un CPGraphHostingView. - Ce sera pas travail.

Vous devez créer un objet CPGraphHostingView réel, alors invoquez -setHostedGraph: dessus.

Ainsi, votre code devrait ressembler à ceci:

CGRect someFrame = ...; 
CPGraphHostingView *hostingView = [[CPGraphHostingView alloc] initWithFrame:someFrame]; 
graph = [[CPXYGraph alloc] initWithFrame: hostingView.bounds]; 

hostingView.hostedGraph = graph; 
+0

Si je ne puis utiliser UIView comment il déterminer quel est le UIView hostView pour ce terrain de base? J'ai quatre vues sur mon ViewController. Alors, que peut-on faire dans ce cas? –

+0

Merci Jacob Relkin. Ça a marché!! –

+0

Hmmmm gr8 qui a fonctionné pour moi aussi !!! –

Questions connexes