@IBAction func keyboardReturnKeyTapped(_ sender: UITextField) {
if let text = sender.text {
print(text)
}
}
Excerpt From: Apple Education. “Develop in Swift Fundamentals.” Apple Inc. – Education, 2021. Apple Books. https://books.apple.com/jp/book/develop-in-swift-fundamentals/id1556365994?l=en
I am learning how to develop iOS apps by the official guide “Develop in Swift Fundamentals.”
The book shows sample code above.
This code seems not to dismiss the keyboard after pressing return-key.
So, I used an instance method “.resignFirstResponder” like code below.
公式のテキストに載っているコードを試した所、キーボードがリターン・キーを押しても消えなかった。
そこでインスタンス・メソッド .resignFirstResponder を使ってみた。
@IBAction func keyboardReturnKeyTapped(_ sender: UITextField) {
if let text = sender.text {
print(text)
}
sender.resignFirstResponder()
}
Please check the page below.
参考ページ
“What is primaryActionTriggered event”
https://developer.apple.com/forums/thread/103127