0
我想知道選擇pickerView值的正確方法是什麼。Swift ios從pickerView中獲取選定的值
現在我的代碼是這樣的:
var timeLeft: Int?
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if pickerView.tag == 0 {
TimeLeftBtnLabel.text = TimeLeftPickerData[row]
timeLeft = row
}
}
,或者我應該做這樣的:
var timeLeft: Int?
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if pickerView.tag == 0 {
TimeLeftBtnLabel.text = TimeLeftPickerData[row]
timeLeft = TimeLeftPicker.selectedRowInComponent(0)
}
}