CPTGraphHostingView in a UIView

北慕城南 提交于 2020-01-15 08:58:14

问题


I was really impressed, and really grateful about the answers I recived last time I asked here.

I have this problem with Core Plot. I want to have a CPTGraphHostingView inside my UIView so I can have things like labels and scroll views below it.

I am using XCode 3.2 by the way.

How do I do this programmatically? Or with the Interface builder if possible.(I need the instructions to be detailed as im I bit new to this sort of thing) Thanks for your support.


回答1:


If you want to add a core plot graph to a UIView you have to add a CPTGraphHostingView as a subview to the UIView. In the example below, hostingView is a UIView and graphObject is a CPTXYGraph.

CPTGraphHostingView *graphHostingView = [[CPTGraphHostingView alloc] initWithFrame:hostingView.bounds];

[hostingView addSubview:graphHostingView];

graphHostingView.hostedGraph = graphObject;



回答2:


Simple adding CPTGraphHostingView as a subView of UIView [programatically] didn't work for me.

I have searched through many threads and at the end I tried the simplest way to do this - I have created new UIView in interface builder and in this view I have created another UIView and change it to CPTGraphHostingView. Now I can simply create chart [like in tutorials] and link its main UIView anywhere I want.

I don't know why this didn't work programatically but it works from Interface Builder.

I use Xcode 4.2 and Core plot 1.0



来源:https://stackoverflow.com/questions/7645935/cptgraphhostingview-in-a-uiview

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