-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard shifts vertically when it loads #88
Comments
I see this many versions back. However, it does not appear on hones with a home button. Any ideas what may be causing this? |
Not sure. One thing I thought I might try is forcing the keyboard to a certain height rather than letting the height be determined by auto-layout of the stack view's contents. Do you know how I might do this? I cannot get the recommended solution for this (search "height" in this document) to work. Assuming that class KeyboardViewController: UIInputViewController {
var heightConstraint: NSLayoutConstraint?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if heightConstraint == nil, let view = view {
let constraint = NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 600)
view.addConstraint(constraint)
heightConstraint = constraint
}
}
} causes the following error to appear
and I don't know how to resolve that. I've tried tweaking the priority of my constraint like this suggests but that seems to just make the error go away without making my constraint effective. |
Ok I found that I can force the keyboard to a height by adding the constraint like // In `KeyboardViewController#viewDidLoad`
view.heightAnchor.constraint(equalToConstant: 500).isActive = true I still get the dueling constraints warning from the previous comment, but this height constraint wins out. Doesn't fix the problem, unfortunately—the keyboard still shifts vertically. Doesn't seem to matter whether the forced height is greater or less than the system keyboard. |
Alas, the shifting seems to be related to iOS removing its own autocomplete toolbar. With that setting (called "Predictive") disabled: Much better, although still with a small shift upward (something else system-related?). Ah well. At least this is a clearer avenue for a Radar (I'll file at some point) and users who are bothered by the larger shift can be directed to disable the iOS setting. |
Annoying! I guess this is beyond the control of the library? |
Yeah I guess so. Will close this out for now. |
Bummer :( |
Running the demo keyboard on
master
in the iPhone 11 Pro simulator, I seeThe big vertical space that appears at the top looks kind of similar to the space allotted for the autocomplete toolbar, so I tried disabling that by commenting out this line. Curiously, that made the problem only more pronounced:
The text was updated successfully, but these errors were encountered: