быстрая клавиатура скрытия для программного просмотра в текстовом поле - PullRequest
0 голосов
/ 17 октября 2018

Я реализую представление выбора программно по щелчку текстового поля.

Вот моя функция:

func pickUpMarque(_ textField : UITextField){

    // UIPickerView
    self.PickerViewCarMarque = UIPickerView(frame:CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 216))
    self.PickerViewCarMarque.delegate = self
    self.PickerViewCarMarque.dataSource = self
    self.PickerViewCarMarque.backgroundColor = UIColor.white
    TextFieldCarMarque.inputView = self.PickerViewCarMarque

    // ToolBar
    let toolBar = UIToolbar()
    toolBar.barStyle = .default
    toolBar.isTranslucent = true
    toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue: 255/255, alpha: 1)
    toolBar.sizeToFit()

    // Adding Button ToolBar
    let doneButton = UIBarButtonItem(title: "Valider", style: .plain, target: self, action: #selector(AddCarViewController.doneMarqueClick))
    let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
    let cancelButton = UIBarButtonItem(title: "Fermer", style: .plain, target: self, action: #selector(AddCarViewController.cancelMarqueClick))
    toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
    toolBar.isUserInteractionEnabled = true
    TextFieldCarMarque.inputAccessoryView = toolBar

}

Проблема в том, что когда я нажимаю на textField, он систематически запускает клавиатуру по умолчанию.Если я отключаю редактирование на Xcode, он просто ничего не отображает.

Я хочу, чтобы вместо клавиатуры отображался вид выбора.

Не могли бы вы показать мне решение?

Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...