###前提・実現したいこと
このページを参考にUIAlertControllerにテキストフィールドを追加して表示しています。
このテキストフィールドに入力された文字数をカウントしたいです。
テキストフィールドのデリゲートを利用すると思うのですが、どのようにしたら良いのかわかりません。
ご教示お願い致します。
###該当のソースコード
swift
1@IBAction func tapButton(_ sender: UIButton) { 2 let alert = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .alert) 3 4 // OKボタンの設定 5 let okAction = UIAlertAction(title: "OK", style: .default, handler: { 6 (action:UIAlertAction!) -> Void in () 7 }) 8 alert.addAction(okAction) 9 10 // キャンセルボタンの設定 11 let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) 12 alert.addAction(cancelAction) 13 14 // カスタムテキストフィールドを追加 15 alert.addTextFieldWithConfigurationHandler({(text:UITextField!) -> Void in 16 }) 17 alert.addTextFieldWithConfigurationHandler({(text:UITextField!) -> Void in 18 }) 19 20 present(alert, animated: true,completion: nil) 21 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。