I've a many textfield and a pickerView
with toolBar
and it has a done button
. My issue is I can't select the first row from the picker. While I have debugged in the didSelectRow but it won't run inside it. So please where would be my issue?
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
var value = currentPickerArray[row]
textFieldOutletArray[currentTag].text = value
}
Just replace didSelect
method in your sample code like as bellowed. it will working fine.
@IBAction func doneBtn(sender: AnyObject) {
var row = pickerView.selectedRowInComponent(0);
NSLog("value L %d", row)
pickerView(pickerView, didSelectRow: row, inComponent:0)
}
Hope this help you.
suchit kushwaha
In the titleForRow
function add this line of code. It shows first row selected:
textField.text = pickerArray.objectAtIndex(row).objectForKey("Name") as? String
来源:https://stackoverflow.com/questions/31206213/selecting-first-row-in-uipickerview-issue