UIButtonを押したときに表示する必要があるピッカービューがあります。 UIButtonのテキストは、選択された行のテキストに変更されます。しかし、どのようにボタンのピッカービューを開始するのですか?Picker View Swift
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
override func viewDidLoad() {
super.viewDidLoad()
picker.delegate = self
picker.dataSource = self
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return CountryData.count
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
CountryButton.setTitle(CountryData[row], for: .normal)
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return CountryData[row]
}
@IBAction func Country(_ sender: AnyObject) {
CountryButton.inputView == picker
}
これは
「動作しません」と定義します。何が問題なのですか? – rmaddy
アンボットからピッカービューを開始してそのアンボットのテキストを変更することはできません。私はuitextfeildで行うことができますが、uibuttonではできません。 – ahmed
'UIButton'(' unbutton'のようなものはありません)には 'inputView'がありません。ボタンをタップしたときにピッカービューが表示されるようにするには、そのコードをすべて自分で書き込む必要があります。 – rmaddy