У меня есть UIPickerView и кнопка.Я хочу, если я выберу необработанный номер 0, то кнопка не будет включена, и наоборот.У меня есть эта конструкция в моем коде:
import UIKit
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
...
@IBOutlet weak var buttonOutlet: UIButton!
@IBOutlet weak var firstPicker: UIPickerView!
@IBOutlet weak var secondPicker: UIPickerView!
let firstData = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"]
let secondData = ["00", "10", "20", "30", "40", "50"]
@IBOutlet weak var firstLabel: UILabel!
@IBOutlet weak var secondLabel: UILabel!
var first: Int!
var second: Int!
var firstRaw = 1
var secondRaw = 0
...
override func viewDidLoad() {
super.viewDidLoad()
self.firstPicker.delegate = self
self.firstPicker.dataSource = self
self.secondPicker.delegate = self
self.secondPicker.dataSource = self
firstPicker.selectRow(firstRaw, inComponent: 0, animated: true)
secondPicker.selectRow(firstRaw, inComponent: 0, animated: true)
if (self.firstRaw == 0) && (self.secondRaw == 0) {
self.buttonOutlet.isEnabled = false
} else {
self.buttonOutlet.isEnabled = true
}
...
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if pickerView == firstPicker {
...
} else {
...
}
Почему эта конструкция не работает?