Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 拖动时在CorePlot中获取点_Ios_Xcode_Swift_Graph_Core Plot - Fatal编程技术网

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内部层的浅层副本,因此在使用它转换坐标时可能无法正确布局。因为图形已经是一个图层,并且已经布局好,所以直接使用它更容易、更快。