我在互联网上查了一下,但找不到我的问题的答案。对不起,如果它是我没有找到的地方。
所以我有一个带有名称的选择器视图,每个名称都有一个值。我想在另一个计算中添加这些值。这是代码:
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var PickerPres: UIPickerView!
@IBOutlet var LabelPres: UILabel!
let PVpres:[(name: String, numb: Double)] = [("Blue",1), ("Red",2), ("Green",3)]
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return PVpres[row].name
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return PVpres.count
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
LabelPres.text = PVpres[row].name
}
我也有
var color = Float (ColorTextField.text!)!
var item = Float (ItemTextField.text!)!
var source = Float (SourceTextField.text!)!
我想将分配给pickerView中项目的麻木添加到这个计算中:
Total = color * PVpres[0].numb / item* source
但它没有用
谢谢
JC