背景当我使用CPTPGraphHostingView 时,ImageView被倒置(翻转)
我在我的iPhone应用程序中使用核心图1.0。 所有的工作正常,graphics绘制完美,但我面临一个奇怪的问题,graphics页面上的所有控件(CPTPGraphHostingView)被镜像。
即:在这个xib文件中,我将顶级UIView的Identity类中的类设置为CPTPGraphHostingView,然后出现问题。
请帮我解决这个问题。 控件在界面生成器中正确显示,但是当我运行项目时,所有的东西都搞混了。
即使我试图以编程方式添加背景图像,但也是镜像。
这个答案的参考:
- 核心小区谷歌组
- 相关SO问题
我开始知道整个CPTPGraphHostingView颠倒了,以支持Mac OS和iOS。 这是devise,而不是一个错误。
所以从给定的链接解决scheme是:
- 添加两个视图到你的xib文件 ,types
CPTPGraphHostingView
(用于添加graphics)和另一个UIView
types(用于添加任何其他UI控件,背景等)。 您可以通过修改“File's Owner window
View Identity tab
中的heading Class Identity
下的“Class field
来修改视图的types。 - 现在将graphics添加到CPTPGraphHostingView并将其他ui控件添加到其他视图(UIView)
- 故事结局
更新:如果将CPTPGraphHostinView添加到接口中,则不会显示其他组件,因此您必须设置主题,并将CPTXYGraph填充为零。 即你初始化你的CPTXYGraph后添加以下行:
CPTTheme *theme = nil; [barChart applyTheme:theme]; // barChart is my CPTXYGraph barChart.fill = nil; barChart.plotAreaFrame.fill = nil;
注意::添加CPTPGraphHostingView,使其成为顶级UIView的子级,其他组件位于顶级UIView中,并且CPTPGraphHostingView高于所有其他组件。
尝试self.view = (CPTPGraphHostingView *)view