Closed ghost closed 9 years ago
Here is the fix. In a nutshell, just use a 'min()' function to determine if new frame is outside of the bounds of your containing view:
self.view.addKeyboardNonpanningWithFrameBasedActionHandler({[unowned self] (keyboardFrameInView, opening, closing) -> Void in
var toolbarFrame = self.messageToolbar.frame
// Ensure message bar doesn't move outside of modal view's bounds
toolbarFrame.origin.y = min(keyboardFrameInView.origin.y - toolbarFrame.size.height, self.view.frame.size.height - toolbarFrame.size.height)
self.messageToolbar.frame = toolbarFrame
}, constraintBasedActionHandler: nil)
I am trying to use this library to handle a 'message bar' (similar to Messages). It works perfectly on the iPhone, but when used in an iPad modal, dismissing the keyboard causes the message bar to animate with it and once it hits the bottom of the modal view, it moves out of view. Is there a way to ensure that the attached view respects the lower bounds of its superview when the keyboard is dismissing?
FYI - My message bar is just a UIView with a UITextView and UIButton.