enter image description here enter image description here
我想以最佳方式将UISlider连接到图表,以计算保证金值。我应该怎么做?我遵循了教程,并使用了步进器,但想使用textfield和UISlider进行尝试
我收到此消息:
由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[
setValue:forUndefinedKey:]:此类不适用于键iosStepper的键值编码。'
import UIKit
import Charts
class ViewController: UIViewController {
// @IBOutlet weak var iosStepper: UIStepper!
@IBOutlet weak var iosSlidder: UISlider!
// @IBOutlet weak var macStepper: UIStepper!
//
@IBOutlet weak var macSlidder: UISlider!
@IBOutlet weak var pieChart: PieChartView!
var iosDataEntry = PieChartDataEntry(value: 0)
var macDataEntry = PieChartDataEntry(value: 0)
var numberOfDownloadsDataEntries = [PieChartDataEntry]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
pieChart.chartDescription?.text = ""
iosDataEntry.value = Double(iosSlidder.value)
iosDataEntry.label = "iOS"
macDataEntry.value = Double(macSlidder.value)
macDataEntry.label = "iOS"
numberOfDownloadsDataEntries = [iosDataEntry, macDataEntry]
updateChartData()
}
@IBAction func changeiOS(_ sender: UISlider)
{
iosDataEntry.value = Double(sender.value)
updateChartData()
}
@IBAction func changeMac(_ sender: UISlider)
{
macDataEntry.value = Double(sender.value)
updateChartData()
}
func updateChartData()
{
let chartDataSet = PieChartDataSet(entries: numberOfDownloadsDataEntries , label:nil)
let charData = PieChartData(dataSet: chartDataSet)
let colors = [UIColor(named: "iosColor"), UIColor(named: "macColor")]
chartDataSet.colors = colors as! [NSUIColor]
pieChart.data = charData
}
}
2019-07-19 21:33:35.806645 + 0200 testchart [49920:24590312] ***由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[
setValue:forUndefinedKey:]:此类与键iosStepper的键值编码不兼容。'