Search code examples
iosswiftuipickerview

Selecting first row in UIPickerView issue


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
}

Solution

  • 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.