Question

I am trying to use Core Plot to draw a graph, but I my graph view is instantiated as a UIView even though I've set it as CPTGraphHostingView in interface builder:

enter image description here

Here is my code:

usersGraph = [[CPTXYGraph alloc] initWithFrame:usersGraphView.frame];
usersGraphView.hostedGraph = usersGraph;

Why would that happen?

Était-ce utile?

La solution

After playing on and off in Interface Builder trying everything again and again, I've started to search more on StackOverflow and I've stumbled upon this question: Application crashes when working with core plot

Pretty weird, but it wasn't and IB issue (I was sure I was doing the right thing in IB, I've done it a thousand times before), but a linker issue. I don't know why, but I had to add -ObjC to linker flags, and it worked.

Autres conseils

Don't you think that it is strange?

For UIView to have setHostedGraph

-[UIView setHostedGraph:] 

I think you have dragged the IBOutlet for that UIView into the custom class file before adding the CPTGraphHostingViewon the identity inspector. Remove the IBOutlet and drag again.

I downloaded the sample project from corePlot. Make sure that the IBOutlet is CPTGraphHostingView.

enter image description here

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