【问题标题】:Get Points in CorePlot as I drag拖动时在 CorePlot 中获取点
【发布时间】:2015-04-29 06:01:48
【问题描述】:

我想做这样的事情,但使用核心情节:

import UIKit
class ViewController: UIViewController {

@IBOutlet weak var display: UILabel!

@IBAction func pan(sender: UIPanGestureRecognizer) {
 var coordinate = sender.locationInView(UIView?())
display.text = "\(coordinate)"
}}

这会在我平移时获取屏幕点的坐标。是否可以在核心绘图图中执行此操作? (如果可能,使用 plotAreaTouchDown 方法)

【问题讨论】:

    标签: ios xcode swift graph core-plot


    【解决方案1】:

    获取托管视图中的坐标 (sender.locationInView(hostingView))。使用CALayer坐标转换方法将其转换为绘图区域图层坐标系,然后使用绘图空间将其转换为数据坐标。

    【讨论】:

    • 谢谢。不过,我似乎得到了与在 plotAreaWasSelected 函数中使用 plotPointForEvent 不同的观点。 see code
    • plotPointForEvent 之一,使用 plotAreaWasSelected(with UIEvent) 函数。
    • 显示用于转换坐标的代码。听起来您好像在某处遗漏了一步。
    • s1.postimg.org/j8x7vj0jj/Untitled.png graphView 是我的 hostingView。我想我在某处使用了错误的图层。
    • 试试graphViewLayer = graphView.hostedGraph。现有代码创建了graphView内部层的浅拷贝,因此当您使用它来转换坐标时,它可能无法正确布局。由于图已经是一个图层,并且已经布局好了,直接使用起来更加方便快捷。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    相关资源
    最近更新 更多