1
私は3つのUITextViewを持つフォームを持っています。私はテキストフィールドのタップにUIPickerViewを表示したい。私はそれのためのコードの下に書かれている -UIPickerView - UITextView TouchUpで動作しません
@IBAction func selectServiceBook(_ sender: UITextField) {
let message = "\n\n\n\n\n\n"
let alert = UIAlertController(title: "Select Service Book", message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.isModalInPopover = true
let pickerFrame = UIPickerView(frame: CGRect(x: 20, y: 20, width: 200, height: 140)) // CGRectMake(left, top, width, height) - left and top are like margins
pickerFrame.tag = 666
//set the pickers datasource and delegate
pickerFrame.delegate = self
//Add the picker to the alert controller
alert.view.addSubview(pickerFrame)
let okAction = UIAlertAction(title: "OK", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.ServiceBook.text = self.selectedServiceBook
})
alert.addAction(okAction)
self.present(alert, animated: true, completion: {
self.ServiceBook.text = self.selectedServiceBook
})
}
これは、2つのフィールドの仕事をしていませんが、ServiceBookそれキーボードのタップに代わりピッカービューのオープン取得します。画面の他の場所をタップすると、ピッカービューがポップアップします。だから私の前提はEditingDidEndイベントを参照しているEditingDidBeginの代わりです。
どうすれば確認できますか?ここで