Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS custom keyboard height increases on every switch

I have a frustrating issue I have no idea how to solve

When working on a custom keyboard I discovered that on a particular screen - Apple Mail app Reply - custom keyboard gets an increase in height on every keyboard switch.

I narrowed it down to actually zero code

class KeyboardViewController: UIInputViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .yellow
    }
}

Almost everywhere it looks 'normally', that is, takes up the same size as the standard keyboard - e.g. the Messages app

enter image description here

But the Reply screen in the Apple Mail (and maybe few other places) after a few keyboard switches looks like this

enter image description here

What could be causing it?

FWIW the UIKit code that I tried a while ago has only a minimal issue of flashing, then instantly resizing to normal. My current production code is SwiftUI, and it's going to be a pain to rewrite everything back and even then it can return at any point because the zero code version also has this.

EDIT

Also tried the manual constraint path. It made no difference.

class KeyboardViewController: UIInputViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .yellow
        let constr = NSLayoutConstraint.init(item: self.view!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0, constant: 66)
        constr.priority = .defaultHigh
        view.addConstraint(constr)
    }
}
like image 924
Anton Duzenko Avatar asked Dec 14 '25 19:12

Anton Duzenko


1 Answers

What helped for me (as a workaround) was wrapping my SwiftUI with KeyboardKit. No idea still what to do with UiKit.

like image 156
Anton Duzenko Avatar answered Dec 16 '25 15:12

Anton Duzenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!