Ios 快速获取错误的核心图:“;缺少参数‘的参数;框架&x2019;“随时待命”;
我正在尝试使用swift的核心图,我觉得非常接近,除了一个错误。到目前为止,我的代码是:Ios 快速获取错误的核心图:“;缺少参数‘的参数;框架&x2019;“随时待命”;,ios,swift,core-plot,Ios,Swift,Core Plot,我正在尝试使用swift的核心图,我觉得非常接近,除了一个错误。到目前为止,我的代码是: class ViewController: UIViewController, CPTPlotDataSource { @IBOutlet weak var graphView: CPTGraphHostingView! override func viewDidLoad() { super.viewDidLoad() // create graph
class ViewController: UIViewController, CPTPlotDataSource {
@IBOutlet weak var graphView: CPTGraphHostingView!
override func viewDidLoad() {
super.viewDidLoad()
// create graph
var graph = CPTXYGraph(frame: CGRectZero)
graph.title = "Hello Graph"
graph.paddingLeft = 0
graph.paddingTop = 0
graph.paddingRight = 0
graph.paddingBottom = 0
// hide the axes
var axes = graph.axisSet as CPTXYAxisSet
var lineStyle = CPTMutableLineStyle()
lineStyle.lineWidth = 0
axes.xAxis.axisLineStyle = lineStyle
axes.yAxis.axisLineStyle = lineStyle
// add a pie plot
var pie = CPTPieChart()
pie.dataSource = self
pie.pieRadius = (self.view.frame.size.width * 0.9)/2
graph.addPlot(pie)
self.graphView.hostedGraph = graph
}
func numberOfRecordsForPlot(plot: CPTPlot!) -> UInt {
return 4
}
func numberForPlot(plot: CPTPlot!, field fieldEnum: UInt, recordIndex idx: UInt) -> NSNumber! {
return idx+1
}
}
我收到的错误来自以下行:var pie=CPTPieChart()
我的错误是:
核心绘图出现快速获取错误:“调用中缺少参数“frame”的参数”
我正在学习一个教程,swift可能已经改变了,但是我对这门语言还不熟悉,似乎无法解决这个问题。提前感谢。我在开发另一个应用程序时遇到了类似的问题。根据我的经验,CGRectZero给Swift带来了问题。尝试使用实际的CGRect或调用
var pie = CPTPieChart(frame: CGRectMake(x,y,width,height))
您需要添加一个CGRect作为帧参数