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

送分小仙女□ 提交于 2019-12-02 05:31:26

问题


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) are mirrored.

Ie: On that xib file, I set the class in class Identity of top UIView to CPTPGraphHostingView, then problem arises.

Please help me how to solve this. The controls appear correctly in interface builder, but when I run the project all gets messed up.

Even I have tried to add background Image programatically, but that also is mirrored.


回答1:


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.




回答2:


Try self.view = (CPTPGraphHostingView *)view



来源:https://stackoverflow.com/questions/9927031/background-imageview-is-upside-downflipped-when-i-use-cptpgraphhostingview-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!