使用核心图时应用程序崩溃

时间:2012-01-09 10:42:28

标签: iphone core-plot

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'

这是我今天晚上遇到的错误。我将CPTGraphHostingView的类名设置为我在界面构建器中的uiview。

2 个答案:

答案 0 :(得分:16)

我遇到了同样的问题,这对我有用:

  

从Xcode的导航器面板中选择您的项目,然后   突出显示Build Settings选项卡。过滤设置或找到“其他”   链接器Flags'从此列表中,然后将-ObjC -all_load添加到这些   设置

(从这里:http://www.johnwordsworth.com/2011/10/adding-charts-to-your-iphone-ipad-app-using-core-plot/

答案 1 :(得分:1)

ViewController中的视图可能不是CPTGraphHostingView的类型,因此视图无法投射。

可以通过创建CPTGraphHostingView的确切实例来修复,然后将其添加到ViewController的视图中。

CGRect frame = [[self view] bounds];

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

[[self view] addSubview: graphHost];

希望得到这个帮助。

相关问题