【问题标题】:Application crashes when working with core plot使用核心图时应用程序崩溃
【发布时间】:2012-01-09 10:42:28
【问题描述】:
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'

这是我今晚遇到的错误。我在 interfacebuilder 中将 CPTGraphHostingView 的类名设置为我的 uiview。

【问题讨论】:

  • 在你的代码中试试这个 CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
  • CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;这是我在我的代码中使用的!
  • 关于未读取的界面生成器。说未知类是问题,即使我在界面生成器中为 UIView 提供了正确的类以获取条形图

标签: iphone core-plot


【解决方案1】:

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

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

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

【讨论】:

  • “RTFM”的典型情况。我想知道那些链接器标志是干什么用的……CorePlot 的文档真的是坑……嗯。
  • @kiran,这个答案应该被批准。
【解决方案2】:

有可能是你在ViewController中的view不是CPTGraphHostingView的类型,所以view投不出来。

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

CGRect frame = [[self view] bounds];

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

[[self view] addSubview: graphHost];

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 2011-08-24
    • 1970-01-01
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多