因为项目须要用到用户点击 symbol时,弹出对应的具体信息,发现国内解说的比較少,经过一番搜索验证最终解决,先看效果图:

详细须要改动的代码例如以下:

首先要引用托付方法:CPTScatterPlotDelegate、CPTPlotSpaceDelegate

完毕例如以下:

#pragma mark -
#pragma mark CPTPlotSpaceDelegate methods
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceCancelledEvent:(UIEvent *)event
{
return YES;
}
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(UIEvent *)event atPoint:(CGPoint)point
{
return YES;
}
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(UIEvent *)event atPoint:(CGPoint)point
{
NSLog(@"you putdown at point:%@",[NSValue valueWithCGPoint:point]
);
return YES;
}
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(UIEvent *)event atPoint:(CGPoint)point
{
return YES;
} #pragma mark -
#pragma mark CPTScatterPlotDelegate
//当我们选择对应的点时。弹出凝视:
<span style="color:#FF0000;">-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)idx withEvent:(UIEvent *)event
{
</span> if ( symbolTextAnnotation ) {
[xyGraph.plotAreaFrame.plotArea removeAnnotation:symbolTextAnnotation];
symbolTextAnnotation = nil;
}
// Setup a style for the annotation
CPTMutableTextStyle *hitAnnotationTextStyle = [CPTMutableTextStyle textStyle];
hitAnnotationTextStyle.color = [CPTColor greenColor];
hitAnnotationTextStyle.fontSize = 10.0f;
hitAnnotationTextStyle.fontName = @"Helvetica-Bold"; // Determine point of symbol in plot coordinates
NSNumber *x =
[[datasForPlot objectAtIndex:idx] valueForKey:@"x"];
NSNumber *y = [[datasForPlot objectAtIndex:idx] valueForKey:@"y"];
NSString *date = [[datasForPlot objectAtIndex:idx]valueForKey:@"date"]; NSArray *anchorPoint = [NSArray arrayWithObjects:x, y, nil];
// Add annotation
// First make a string for the y value
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setMaximumFractionDigits:2];
NSString *yString = [formatter stringFromNumber:y];
NSString *myString = [NSString stringWithFormat:@"温度:%@\n日期:%@\n事件:%@",yString,date,nil]; // Now add the annotation to the plot area
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:myString/*yString*/ style:hitAnnotationTextStyle];
symbolTextAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:xyGraph.defaultPlotSpace anchorPlotPoint:anchorPoint];
symbolTextAnnotation.contentLayer = textLayer;
symbolTextAnnotation.displacement = CGPointMake(0.0, 20.0);
[xyGraph.plotAreaFrame.plotArea addAnnotation:symbolTextAnnotation]; // NSLog(@"index:%lu,event:%@",(unsigned long)idx,event);
}

千万别忘记了依据自定义的设置对应的delegate = self;

红色标注的就是我们实现该功能的重点

对了。忘记说一点,该点很重要。不然你手指点击不灵活。我们的symbol那么小。还要点击到它的中心才干触发以下的方法,这多难啊,有个參数设置一下就搞定了,设置它的触发范围:

    CPTScatterPlot *boundLinePlot = [[CPTScatterPlot alloc]init];
boundLinePlot.<span style="color:#FF0000;">plotSymbolMarginForHitDetection</span> = 5.0f;//设置symbol点的外沿范围。以用来检測手指的触摸

ok搞定

其它的看凝视。不想再多加说明了

代码传送门:http://download.csdn.net/detail/u012951123/7521733

CorePlot学习六---点击scatterPlot中的symbol点时弹出对应的凝视的更多相关文章

  1. 解决Windows Server2008 R2中IE开网页时弹出阻止框

    使用Windows Server2008,用IE打开网站时会弹出“Internet Explorer增强安全配置正在阻止来自下列网站的此应用程序中的内容”的对话框.如下图所示: 2011-10-14_ ...

  2. 解决Windows Server2008 R2中IE开网页时弹出阻止框(Windows Server2008网页无法打开的问题)

    相信使用Windows Server2008的朋友都遇到过这种情况,用IE打开网站时会弹出“Internet Explorer增强安全配置正在阻止来自下列网站的此应用程序中的内容”的对话框.如下图所示 ...

  3. 解决eclipse中运行web项目时弹出的"Port 8080 required by Tomcat 9.0 Server at localhost is already in use...

    1.tomcat默认端口是8080,可以修改通过tomcat的端口 修改tomcat\conf\server.xml     结果运行程序,还是报"Port 8080 required by ...

  4. EBS OAF开发中实现參数式弹出窗体

    EBS OAF开发中实现參数式弹出窗体 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) 概览 參数式弹出窗体和嵌入式弹出窗体不一样,它拥有独立 ...

  5. (原)android的alertdialog中加入edittext但是不弹出软键盘等问题的解决与原因

    摘要:alertdialog中加入edittext但是不弹出软键盘等问题网上有很多不管用的解决方案, 本文意在给出更有效的解决办法,并初步探究其原因 正文 在对话框中插入文本框是十分常见的需求 通常我 ...

  6. 禁止手机页面中A标签长按弹出路径框

    //禁止手机页面中A标签长按弹出路径框    window.onload=function(){        document.documentElement.style.webkitTouchCa ...

  7. Android定位&地图&导航——基于百度地图,实现自定义图标绘制并点击时弹出泡泡

    一.问题描述 上一次我们使用百度地图实现基本的定位功能,接下来我们继续实现搜索和定位,并使用LocationOverlay绘制定位位置,同时展示如何使用自定义图标绘制并点击时弹出泡泡 如图所示: 二. ...

  8. 设置电脑中的某个程序不弹出UAC用户控制提示的方法

    有用户发现在电脑开机后总是会弹出UAC用户账户控制窗口,这是因为电脑中的某个程序设置了开机启动,这样就会在开机后启动该程序时出现UAC提示.如果想要省略该提示,可以在电脑中设置该程序不弹出UAC用户控 ...

  9. VS2015+OpenGL4.0开发编译时弹出错误:glaux.lib(tk.obj) : error LNK2019: 无法解析的外部符号 _sscanf,该符号在函数 _GetRegistrySysColors@8 中被引用

    一.问题描述: VS2015+OpenGL4.0开发编译时弹出如下所示的错误: 1>glaux.lib(tk.obj) : error LNK2019: 无法解析的外部符号 _sscanf,该符 ...

随机推荐

  1. HDU 4418 高斯消元法求概率DP

    把两种状态化成2*n-2的一条线上的一种状态即可.很容易想到. 高斯列主元法,不知为什么WA.要上课了,不玩了...逃了一次课呢.. #include <iostream> #includ ...

  2. Ruby中写换行

    Ruby中写换行 print("Hello,\nRuby\n!\n") print("Hello, Ruby ! ") 这两个竟然是一样的:就是说,可以直接回车 ...

  3. HDOJ 2189 悼念512汶川大地震遇难同胞——来生一起走 【母函数】

    题意:非常清楚不解释. 策略:如题. 就是个简单的母函数的改变. 这道题做了好久,才明确是那有毛病,还是理解的不够深刻. AC代码: #include<stdio.h> #include& ...

  4. I hate it (线段树)

    B - I Hate It Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  5. poj3101--Astronomy(分数的最小公倍数)

    题目链接:id=3101">点击打开链接 题目大意:有n个行星,给出每个行星的旋转的周期.问最少多少时间后n个行星会在一条直线上,初始点在一起,不存在全部的行星都有同一个周期 如果A行 ...

  6. 110_leetcode_Best Time to Buy and sell Stock II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  7. nodeJS npm grunt grunt-cli

    1.安装好nodeJS后 ,一般都会把npm也安装好的.nodeJs集成npm的,可通过在cmd 分别运行 node -v和 npm -v来查看他们的版本,假设显示可说明可继续以下的操作 2.想安装g ...

  8. 在Redhat Linux中执行非Redhat的Openstack, Redhat将对其Linux不提供支持

    一声叹息. IBM.HP.Dell, Mirantis, Piston等.请问.你们还把你们的Openstack部署在Redhat中吗? http://blogs.wsj.com/digits/201 ...

  9. vue 结合 echarts

    http://blog.csdn.net/mr_wuch/article/details/70225364

  10. php正则检测字符串由单一字符组成

    $str = 'aaa' $firstChar = substr($str , 0, 1); $pattern = "/^[$firstChar]+$/"; $ret = preg ...