0

Почему мой массив не отображается в пикере?

    // Array of values in picker
let numeralSystems = ["16 NS","10 NS", "8 NS", "2 NS" ]

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return numeralSystems[row]
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return numeralSystems.count
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    fromLabel.text = numeralSystems[row]
}
0

1 ответ 1

1

Установите делегат для протокола UIPickerViewDataSource:

override func viewDidLoad() {
    super.viewDidLoad()

    pickerView.delegate = self
}

Добавьте протокол для контроллера:

class TheNameOfYourController: UIViewController, UIPickerViewDataSource {}
4
  • А куда его нужно вставить? 24 ноя 2018 в 11:36
  • @МаксимАлексеев где вы пикер создаете? Программно или сториборд? 25 ноя 2018 в 9:31
  • Виталий,я его создаю в сториборде 27 ноя 2018 в 14:58
  • @МаксимАлексеев посмотрите обновление 28 ноя 2018 в 11:40

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.