skip to Main Content

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

Answers


  1. you can use to dismiss the keyboard

    view.endEditing(true)
    
    Login or Signup to reply.
  2. override func viewDidLoad() {
        super.viewDidLoad()
        
         let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKb))
    
        view.addGestureRecognizer(tap)
    }
    
    @objc func dismissKb() {
        view.endEditing(true)
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search