如何在coreplot中设置plot delegate [英] how to set plot delegate in coreplot

查看:115
本文介绍了如何在coreplot中设置plot delegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是此链接中的后续问题: coreplot条点击无效答案是:将情节委托设置为条形图委托对象。可以告诉我如何。我正在尝试创建一个简单的条形图10天,没有教程用简单的单词解释过程。这将是一个很大的帮助,我真的很感激。谢谢。

This is a follow up question from this link : coreplot bar tap not working and the answer is : Set the plot delegate to your bar plot delegate object. PLease can anybody tell me how .I am trying to create a simple bar-chart with on tap for 10 days and there is no tutorial which explains the process in simple words. It would be a great help and I would really appreciate it .Thanks in advance.

推荐答案

你需要设置你的CPTBarPlot委托。在设置之前,CPTBarPlot对象不知道将委托方法发送到何处。

You need to set your CPTBarPlot delegate. Until it is set, the CPTBarPlot object doesn't know where to send it's delegate method to.

GraphView.m

寻找 plot.dataSource = self 并添加行 plot.delegate = self (它在您创建<的代码中code> CPTBarPlot * plot )

Look for plot.dataSource = self and add the line plot.delegate = self (it's in the code where you are creating your CPTBarPlot *plot)

然后一定要将委托方法实现添加到GraphView.m。

Then be sure to add the delegate method implementation to GraphView.m.

这应该有效,但值得指出的是,您应该不应该在视图中放置dataSource和委托方法。这是视图控制器的工作,因为控制器在视图和模型之间进行调解,并指导用户交互。同样,你的 generateData 方法不属于视图,数据应该通过视图控制器设置/发送到视图(我猜它只是出于测试目的,但是最好开始,因为你的意思继续......)。

That should work, but it's worth pointing out that you should should not really be putting your dataSource and delegate methods in your view. This is a job for the view controller, as the controller mediates between the view and it's model, and directs user interaction. Similarly, your generateData method does not belong in the view, the data should be set / sent to the view via the view controller (I guess it's there just for testing purposes, but best to start as you mean to go on...).

这篇关于如何在coreplot中设置plot delegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆