-1

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?

  • 1
    Hard to say the best method without seeing some code or detail, but this thread has many answers: https://stackoverflow.com/questions/741185/easy-way-to-dismiss-keyboard – jnpdx Jan 10 '22 at 01:26
  • There really isn't much code. Just a label connected as an outlet – Logan Cohen Jan 10 '22 at 01:45
  • 2
    What specifically is "label"? Because `UILabel` doesn't generally have a keyboard associated with it. Is it a `UITextField`? Did you check out the answers in the link I posted? – jnpdx Jan 10 '22 at 01:46
  • you can use IQKeyboardManager instead of normal keyboard install it using ** pod IQKeyboardManager** – Noor Ahmed Natali Jan 10 '22 at 05:12

2 Answers2

0

you can use to dismiss the keyboard

view.endEditing(true)
Anh vu
  • 46
  • 5
0
override func viewDidLoad() {
    super.viewDidLoad()
    
     let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKb))

    view.addGestureRecognizer(tap)
}

@objc func dismissKb() {
    view.endEditing(true)
}
bdeviOS
  • 449
  • 1
  • 6