References for this answer:
I came to know that the whole CPTPGraphHostingView is inverted upside down to support both Mac OS and iOS. This is by design and is not a bug.
So the solution from the given links is that:
- Add two Views to your xib file, one of type
CPTPGraphHostingView
(for adding graph) and the other of type UIView
(for adding any other ui controls, backgrounds etc). You can modify the type of View by modifying Class field
under the heading Class Identity
in View Identity tab
of File's Owner window
.
- Now add the graph to CPTPGraphHostingView and add other ui controls to the other view(UIView)
- End of story
UPDATE:
If you add CPTPGraphHostinView to interface, no other components will be visible, for that you'll have to set theme, and fill of CPTXYGraph to nil. Ie add following lines after you initialize your CPTXYGraph:
CPTTheme *theme = nil;
[barChart applyTheme:theme]; // barChart is my CPTXYGraph
barChart.fill = nil;
barChart.plotAreaFrame.fill = nil;
NOTE:: Add CPTPGraphHostingView such that it is child of top level UIView, and other components are in top level UIView, and CPTPGraphHostingView is above all other components.