Messagekit: Adding ConversationViewController as a child view controller the messageInputBar not display on the view

Created on 3 Nov 2017  路  10Comments  路  Source: MessageKit/MessageKit

General Information

  • MessageKit Version: 0.10.0

  • iOS Version(s): iOS 10.3

  • Swift Version: Swift 4

  • Devices/Simulators: Device

  • Reproducible in ChatExample? (Yes/No): Yes

What happened?

When I try to add ConversationViewController as a child view controller on InboxViewController that time messageInputBar does not display on the view.

Below code

let contentVC:UIViewController = ConversationViewController()
addChildViewController(contentVC)
self.view.addSubview(contentVC.view)
contentVC.didMove(toParentViewController: self)

What did you expect to happen?

The messageInputBar must display on the view even though I add ConversationViewController as a child view.

question

Most helpful comment

Hi @BasThomas

I just added self.becomeFirstResponder() in ConversationViewController ViewDidAppear as per sugested by @Wotafak and @SD10 .

All 10 comments

@nfasate I think you have to call:

messagesViewController.becomeFirstReponder()

cc @cwalo I think he had a solution for this

Hi SD10,

Thanks for quick reply, but I don't get it from where I have to call messagesViewController.becomeFirstReponder() in my code.

I guess the size of messageInputBar is always return zero when I have added ConversationViewController as a child view.

Thanks.

@nfasate try calling messagesViewController.becomeFirstReponder() in viewDidAppear

@Wotafak,

I am not able to call messagesViewController.becomeFirstReponder() in ViewDidAppear it throw compilor errorUse of unresolved identifier 'messagesViewController'

@nfasate It looks like your MessagesViewController is called contentVC.

@SD10 Even after using contentVC.becomeFirstResponder(), the MessageViewController doesn't show messageInputBar.

@SD10 Thanks a ton !! it worked.

Hey @nfasate - can you share how you solved the problem in the end?

Hi @BasThomas

I just added self.becomeFirstResponder() in ConversationViewController ViewDidAppear as per sugested by @Wotafak and @SD10 .

My scenario sounds slightly different as I have two view controllers added as children - one being the MessagesViewController. I'm just toggling their hidden state depending on which is selected. But yeah, to handle the input bar, I call becomeFirstResponder and when I want it go away, I callinputBar.inputTextView.resignFirstResponder and messagesViewController.resignFirstResponder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emmanuelay picture emmanuelay  路  3Comments

TheDarkCode picture TheDarkCode  路  3Comments

yspreen picture yspreen  路  3Comments

pawankmrai picture pawankmrai  路  3Comments

nitrag picture nitrag  路  3Comments