Background ImageView is upside down(flipped) when I use CPTPGraphHostingView [Core plot]

前端 未结 2 1578
长情又很酷
长情又很酷 2021-01-21 20:44

I am using core plot 1.0 in my iphone app. All works fine, graphs are drawing perfectly, But I am facing a weird problem that All the controls on graph page(CPTPGraphHostingView

相关标签:
2条回答
  • 2021-01-21 21:04

    References for this answer:

    • Core plot google group
    • Related SO question

    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:

    1. 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.
    2. Now add the graph to CPTPGraphHostingView and add other ui controls to the other view(UIView)
    3. 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.

    0 讨论(0)
  • 2021-01-21 21:20

    Try self.view = (CPTPGraphHostingView *)view

    0 讨论(0)
提交回复
热议问题