I'm trying to have core plot to automatically redraw a b开发者_如何学Goar chart when orientation is changed just like in the provided example (CPTTest-iphone). I made some search on google but no luck. I do have the the CPTGraphHostingView property autoresizingMask set to true and in the nib file its view mode is set to "Scale to Fill". Any ideas what I'm doing wrong or other configuration i am missing? Thank you.
When you detect an orientation change, you need to change the dimensions of your CPTGraphHostingView
, then call reloadData
on all the plots in your graph. Something like this:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
self.hostingView.frame = CGRectMake( /* new dimensions for your hosting view */ );
for (CPTPlot *p in self.graph.allPlots)
{
[p reloadData];
}
}
You might also need to fix up the labels and tick marks on your axes, and the padding on the plotAreaFrame to accommodate the new size of the hosting view.
精彩评论