diff --git a/modules/keyboard-avoiding-view/ios/KeyboardAvoidingView.swift b/modules/keyboard-avoiding-view/ios/KeyboardAvoidingView.swift index ddb3f49..e3c6b58 100644 --- a/modules/keyboard-avoiding-view/ios/KeyboardAvoidingView.swift +++ b/modules/keyboard-avoiding-view/ios/KeyboardAvoidingView.swift @@ -14,6 +14,9 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { return panGestureRecognizer }() private var isScrollViewPanning = false + private lazy var containerBottomAnchorConstraint: NSLayoutConstraint = { + return container.bottomAnchor.constraint(equalTo: bottomAnchor) + }() required init(appContext: AppContext? = nil) { super.init(appContext: appContext) @@ -36,7 +39,7 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { container.heightAnchor.constraint(equalTo: heightAnchor), container.leadingAnchor.constraint(equalTo: leadingAnchor), container.trailingAnchor.constraint(equalTo: trailingAnchor), - container.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor), + containerBottomAnchorConstraint, ]) NotificationCenter.default.addObserver( @@ -72,7 +75,6 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { } @objc private func keyboardWillShow(_ notification: Notification) { - keyboardLayoutGuide.followsUndockedKeyboard = true updateInsets(notification) } @@ -100,6 +102,8 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { UIView.animate(withDuration: animationDuration, delay: 0.0, options: animationOptions) { self.scrollView?.setInsetsFromKeyboardHeight(keyboardHeight) + self.containerBottomAnchorConstraint.constant = -keyboardHeight + self.layoutIfNeeded() } } @@ -108,7 +112,6 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { measurer.removeObserver(self, forKeyPath: "center") measurerHasObserver = false } - keyboardLayoutGuide.followsUndockedKeyboard = false updateInsets(notification, closing: true) } @@ -123,6 +126,8 @@ class KeyboardAvoidingView: ExpoView, UIGestureRecognizerDelegate { return } self.scrollView?.setInsetsFromKeyboardHeight(measurer.frame.height) + self.containerBottomAnchorConstraint.constant = -keyboardHeight + self.layoutIfNeeded() } }