KeyboardLayoutGuide does not work in iMessage app

Viewed 55

I am using the FreshOS KeyboardLayoutGuide extension in order to constrain a view to the top of the keyboard. Although the sample application runs perfectly, when I port the sample code to my iMessage app code, the view is shifted up when the keyboard appears (I set it to bright red in order to see its position underneath the keyboard), but is not constrained to the top of the keyboard as hoped. I am assuming this has something to do with the fact that the MSMessagesAppViewController has some different way of handling the keyboard because of its dynamic height? Or maybe the library calculates the keyboard height using the height of the window?

Here's my code:

import UIKit
import Messages
import KeyboardLayoutGuide

class ExpandedViewController: MSMessagesAppViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        inputContainerView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor).isActive = true
    }

    ...
}
0 Answers
Related