Application crashes when working with core plot

混江龙づ霸主 提交于 2019-12-19 08:04:15

问题


Unknown class CPTGraphHostingView in Interface Builder file.
2012-01-09 16:09:34.242 ChartArea[2595:207] -[UIView setHostedGraph:]: unrecognized selector sent to instance 0x4c064f0
2012-01-09 16:09:34.245 ChartArea[2595:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x4c064f0'

This is the error I am getting this evening. i am setting the class name of to CPTGraphHostingView to my uiview within interfacebuilder.


回答1:


I had the same problem and this worked for me:

Select your project from the navigator panel in Xcode and then highlight the Build Settings tab. Filter the settings or locate ‘Other Linker Flags’ from this list and then add -ObjC -all_load to these settings

(From here: http://www.johnwordsworth.com/2011/10/adding-charts-to-your-iphone-ipad-app-using-core-plot/)




回答2:


It is possible that your view in ViewController is not a type of CPTGraphHostingView, so the view fails to cast.

It can fixed by creating exact instance of CPTGraphHostingView then add it to the ViewController's view.

CGRect frame = [[self view] bounds];

CPTGraphHostingView* graphHost = [[CPTGraphHostingView alloc] initWithFrame:frame];

[[self view] addSubview: graphHost];

Hope this help.



来源:https://stackoverflow.com/questions/8787164/application-crashes-when-working-with-core-plot

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