I am constructing a customized iOS keyboard utilizing UIInputViewController. I wish to toggle between my customized keyboard (with a customized view and accent view) and the system keyboard (default QWERTY). Nevertheless, when I attempt to reset inputView to indicate the system keyboard, I get a clean view as an alternative.
Right here’s what I’m doing in my showEnglishKeyboard perform:
swift
non-public func showEnglishKeyboard() {
// Conceal customized panels
suggestionPanel.isHidden = true
accessoryView.isHidden = false
// Reset to system keyboard
self.resignFirstResponder() // Dismiss present keyboard
DispatchQueue.primary.asyncAfter(deadline: .now() + 0.1) {
self.inputView = nil // Reset inputView to default keyboard
self.reloadInputViews() // Reload keyboard
self.becomeFirstResponder() // Reactivate enter controller
}
}
I’ve additionally overridden viewWillLayoutSubviews to make sure the peak of the customized keyboard matches the system keyboard:
swift
override func viewWillLayoutSubviews() {
tremendous.viewWillLayoutSubviews()
view.body = CGRect(x: 0, y: 0, width: UIScreen.primary.bounds.width, peak: 216) // Normal keyboard peak
}
Moreover, I’ve an inputAccessoryView:
swift
override var inputAccessoryView: UIView? {
return accessoryView
}
The Downside:
Once I toggle again to the system keyboard, I get a clean view as an alternative of the default QWERTY keyboard. The accessoryView additionally disappears.
What I’ve Tried:
Utilizing reloadInputViews() after setting inputView = nil.
Including delays with DispatchQueue.primary.asyncAfter to let the responder state settle.
Making certain that becomeFirstResponder() known as after resetting inputView.
Debug Data:
view.body logs present the proper width and peak (e.g., 320×216 for an iPhone SE).
self.isFirstResponder returns true after calling becomeFirstResponder().
My Purpose:
I wish to:
Present the system keyboard (QWERTY) when inputView is reset to nil.
Hold the inputAccessoryView seen on the high.
What am I lacking? How can I repair this problem? Any assist could be enormously appreciated!