How to automatically change the orientation of the core when the device is rotated?

I am trying to create a main chart to automatically redraw the histogram when the orientation changes in the same way as in the above example (CPTTest-iphone). I did a google search but no luck. I have the autoresizingMask property of the CPTGraphHostingView property equal to true, and in the nib file for its view mode is set to "Scale to fill." Any ideas what I am doing wrong or another configuration I am missing? Thanks.

+4
source share
1 answer

When you detect a change in orientation, you need to resize your CPTGraphHostingView , and then call reloadData on all the graphs in your graph. Something like that:

 -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { self.hostingView.frame = CGRectMake( /* new dimensions for your hosting view */ ); for (CPTPlot *p in self.graph.allPlots) { [p reloadData]; } } 

You may also need to correct the marks and marks on your axes, as well as fill in the Arifka chart to accommodate the new size of the hosting view.

+1
source

All Articles