Closed clayellis closed 6 years ago
Hmm, the embedded gif isn't working. https://giphy.com/gifs/2t9oMHhOAX7E75sNny
@clayellis I'm not sure if this is possible. The MessageInputBar
is the inputAccessoryView
of the controller 🤔
@SD10 right, which is why it isn't a "bug", it's supposed to work that way. I just don't know the fine details of what occurs in the first responder chain when a controller is presented from a controller who is currently the first responder. The closest I've come to achieving the behavior I'm looking for is calling becomeFirstResponder
on the MessagesViewController
in the presentation completion handler:
present(alert, animated: true, completion: { self.becomeFirstResponder() })
But things just get weird from that point. It isn't a good solution.
Other things I've tried:
UIAlertController
and overriding canBecomeFirstResponder
and returning false
.disablesAutomaticKeyboardDismissal
and return false
in the MessagesViewController
.This SO question doesn't have any answers, but leaving a link to it here just in case at some point in the future someone answers or has the same question: https://stackoverflow.com/questions/46996251/inputaccessoryview-animating-down-when-alertcontroller-actionsheet-presented
The trick is to present the alert from the topmost window and viewcontroller.
let topViewController = UIApplication.shared.windows.last!.rootViewController!
topViewController.present(alert, animated: true, completion: nil)
You could also try creating a new UIWindow above the Keyboard by giving it a higher WindowLevel and present the alert there. I suspect that's what Messages is probably doing since the previous is a bit clunky.
@cwalo That'd do the trick! I was going to use another window as a last resort, but it does seem to be a pretty clean solution! Thanks a ton, I really appreciate it.
General Information
MessageKit Version: 13.2
iOS Version(s): 11.3
Swift Version: 4.1
Devices/Simulators: Both
Reproducible in ChatExample? (Yes/No): Yes, if you add these lines to
handleTyping
(just using it as an injection point):What happened?
The
MessageInputBar
animates down offscreen when the alert is presented. It comes back after the alert is dismissed.What did you expect to happen?
The alert to be presented and the
MessageInputBar
to remain visible.My Question
This is happening because
messageInputBar
is theinputAccessoryView
onMessagesViewController
and is the correct behavior in UIKit.My question is how do I prevent the
MessageInputBar
from disappearing when the alert is presented? I've tried overriding some of the first responder properties to prevent the input bar from being "dismissed" but nothing seems to be working quite yet. Is anyone aware of a solution?