How do I dismiss the number pad keyboard?

650 views Asked by At

In Xcode I selected the Number Pad under Keyboard Type for a label. It works fine, but I cannot dismiss the keyboard and it's blocking important content. How do I get the number pad to close?

2

There are 2 answers

0
Anh vu On

you can use to dismiss the keyboard

view.endEditing(true)
0
bdeviOS On
override func viewDidLoad() {
    super.viewDidLoad()
    
     let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKb))

    view.addGestureRecognizer(tap)
}

@objc func dismissKb() {
    view.endEditing(true)
}