テキストフィールドの編集・キーボードリターンキーを押した時
【テキストフィールドを編集・キーボードリターンキーを押した時】
//テキストフィールドインスタンスの生成 var textfield = UITextField() //テキストフィールドを編集状態にする func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { //キーボードを表示する textfield.keyboardType = .alphabet return true } //キーボードリターンキーを押した時の動作 func textFieldShouldReturn(_ textField: UITextField) -> Bool { //キーボードを閉じる textfield.resignFirstResponder() view.endEditing(true) return true } |