错误:“-[UIView setHostedGraph:]:无法识别的选择器”在 iPhone 应用程序中执行核心情节时
当我尝试编译以下代码时出现以下错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIView setHostedGraph:]:无法识别的选择器发送到实例 0x6768c10”
代码:
UIView *ChartView;
ChartView = [[UIView alloc] init];
graph = [[CPXYGraph alloc] initWithFrame: ChartView.bounds];
CPGraphHostingView *hostingView = (CPGraphHostingView *)ChartView;
hostingView.hostedGraph = graph;
可能出了什么问题?
I get the below error when I try to compile the below code:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x6768c10'
Code:
UIView *ChartView;
ChartView = [[UIView alloc] init];
graph = [[CPXYGraph alloc] initWithFrame: ChartView.bounds];
CPGraphHostingView *hostingView = (CPGraphHostingView *)ChartView;
hostingView.hostedGraph = graph;
What could be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在将
UIView
实例(它不响应-setHostedGraph:
)转换为CPGraphHostingView
。 - 这将不起作用。您需要创建一个实际的
CPGraphHostingView
对象,然后在其上调用-setHostedGraph:
。所以,你的代码应该是这样的:
You're casting a
UIView
instance (which does not respond to-setHostedGraph:
) to aCPGraphHostingView
. - This will not work.You'll need to create an actual
CPGraphHostingView
object, then invoke-setHostedGraph:
on it.So, your code should look like this: