7
7

More than 3 years have passed since last update.

【Swift】UIPickerViewのデフォルト値を変更する

Posted at

要約

UIPickerViewのデフォルト値を変更したい場合、以下の2箇所を変更する必要がある。

  • PickerViewを開いた後、選択されている値を変更する
self.pickerView.selectRow(index, inComponent: 0, animated: false)
  • PickerViewで選択された値を表示しているTextFieldなどの値を変更する。
pickerViewTextField.text = optionList[index]

備考

  • selectRowだけ設定すけばいけるやろと思ってハマった…ので備忘録です。
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7