How to prevent popover scaling when keyboard appears?

143 Views Asked by At

My iPad app has a popover with a few UITextFields at the top half.

When tapping a textfield, which makes the keyboard appear, iOS scales (and moves) my popover. I don't want that.

How do I prevent iOS from doing that?

This answer suggests to override some keyboardWillShow() and keyboardWillHide() functions, but it's unclear where these are defined.

1

There are 1 best solutions below

0
David B. On

As mentioned by Leszek in the comments update the popoverPresentationController.popoverLayoutMargins of your UIViewController to accommodate the height of the keyboard:

func configurePopoverPresentationController() {
        let keyboardHeight = 500
        popoverPresentationController.popoverLayoutMargins = UIEdgeInsets(top: 0.0, left: 0.0, bottom: -keyboardHeight, right: 0.0)
    }