Swiftmessages: First responder issue

Created on 30 Sep 2016  路  4Comments  路  Source: SwiftKickMobile/SwiftMessages

I'm currently using SwiftMessages 2.0.
In a chat view, I'm displaying messages notifications while the user is typing text.
When a message comes-in it is granted to be the new first responder which makes the keyboard disappear in consequence.
Do you have any workaround ideas ?

Thanks

Most helpful comment

For future readers, here is how to solve it:

  • Use the configuration to change the presentation context, default is window which display an alert window that take the first responder role and dismiss the keyboard.
  • Change the presentation context to view controller and pick the view controller where you want to show it, it will usually be your rootVC.
var config = SwiftMessages.Config()
config.presentationContext = .ViewController(window.rootViewController)

let view = MessageView.viewFromNib(layout: MessageView.Layout.MessageView)
SwiftMessages.show(config: config, view: view)

All 4 comments

Never mind, found a way to solve it through the View Controller presentation context.

Hi @CallMeSH I'm EXACTLY in the same configuration as your problem. Can you, please explain a little more how did you bypass this issue ?
Thanks !

For future readers, here is how to solve it:

  • Use the configuration to change the presentation context, default is window which display an alert window that take the first responder role and dismiss the keyboard.
  • Change the presentation context to view controller and pick the view controller where you want to show it, it will usually be your rootVC.
var config = SwiftMessages.Config()
config.presentationContext = .ViewController(window.rootViewController)

let view = MessageView.viewFromNib(layout: MessageView.Layout.MessageView)
SwiftMessages.show(config: config, view: view)

Thanks dude ! Didn't understand you were referring to presentationContext for SwiftMessages 馃槄

Was this page helpful?
0 / 5 - 0 ratings