user4401
user4401

Reputation: 446

ios/swift - How to disable keyboard?

I have a simple iOS app with two controllers. One of them holds a webview displaying a website. The website has its own keyboard which appears when editing html input fields. However, when trying to use one of these inputs iOS displays its own built in keyboard.

How to disable keyboard in iOS/swift from popping up in a single controller or within a web view?

Upvotes: 1

Views: 1078

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

You can try

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)

///

@objc func keyboardWillShow(notification: NSNotification) {

    self.view.endEditing(true)
}

Upvotes: 4

Related Questions