Ios 拖动时在CorePlot中获取点
我想这样做,但使用核心图:Ios 拖动时在CorePlot中获取点,ios,xcode,swift,graph,core-plot,Ios,Xcode,Swift,Graph,Core Plot,我想这样做,但使用核心图: import UIKit class ViewController: UIViewController { @IBOutlet weak var display: UILabel! @IBAction func pan(sender: UIPanGestureRecognizer) { var coordinate = sender.locationInView(UIView?()) display.text = "\(coordinate)" }} 当我四处
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var display: UILabel!
@IBAction func pan(sender: UIPanGestureRecognizer) {
var coordinate = sender.locationInView(UIView?())
display.text = "\(coordinate)"
}}
当我四处平移时,这会得到屏幕点的坐标。有可能在核心图中这样做吗?(如果可能,请使用绘图区域触地方法)获取主机视图中的坐标(
sender.locationInView(主机视图)
)。使用CALayer
坐标转换方法将其转换为绘图区域图层坐标系,然后使用绘图空间将其转换为数据坐标。谢谢。我似乎得到了一个不同于在PlotArea中使用plotPointForEvent的点,但是选择了PlotArea。plotPointForEvent one,使用plotAreaWasSelected(带UIEvent)函数。显示用于转换坐标的代码。听起来你好像错过了一步。图形视图是我的主视图。我想我在某个地方使用了错误的图层。请尝试graphViewLayer=graphView.hostedGraph
。现有代码创建graphView内部层的浅层副本,因此在使用它转换坐标时可能无法正确布局。因为图形已经是一个图层,并且已经布局好,所以直接使用它更容易、更快。