Pickerview is closing before done button is pressed on toolbar

I do have a pickerview with toolbar, but when i scroll it closes before I press the done button. the button is there but somehow useless. how to make pickerview close only after pressing the done button?

I added done button like this :

let doneBtn = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(RoundShapeController.dismissKeyboard))

toolbar.setItems([doneBtn], animated: false)

toolbar.isUserInteractionEnabled = true

materialTextField.inputAccessoryView = toolbar

but when i scroll it closes before I press the done button.


Probably, when you scroll you in fact made a selection in picker.


Could you show you delegate func

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {


It should not close the picker (only close on Done action).

Pickerview is closing before done button is pressed on toolbar
 
 
Q