我正在创建一个Clock PickerView,并使用了以下内容:
var countSec = Array(0...10)
var countMin = Array(0...59)
var countHour = Array(0...59)
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if component == 0{
for count in countSec {
return "\(count)"
}
}else{
for count in countMin{
return "\(count)"
}
}
return nil
}
但是当我运行时,所有数据都是0s。
答案 0 :(得分:1)
请勿在{{1}}中使用循环。只需为请求的行返回适当的值即可。
==