Messagekit: MessagesViewController as child view controller is not working

Created on 14 Apr 2020  路  3Comments  路  Source: MessageKit/MessageKit

Hi, Thanks for the best library for messaging, but I am having the issue that when adding MessagesViewController into a containerView its not showing input bar.
I have tried adding view pragmatically and using story board also.
How to fix that, as I am using the latest version as per date. & using swift 5
Help would be appreciated.

public func add(asChildViewController viewController: UIViewController,to parentView:UIView) {
        // Add Child View Controller
        addChild(viewController)

        // Add Child View as Subview
        parentView.addSubview(viewController.view)

        // Configure Child View
        viewController.view.frame = parentView.bounds
        viewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

        // Notify Child View Controller
        viewController.didMove(toParent: self)
    }
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
        let viewController = storyboard.instantiateViewController(withIdentifier: "chatVC") as! ChatViewController
        self.add(asChildViewController: viewController, to: chatView)

this is How I am adding containerView, where ChatView is the ContainerView

Most helpful comment

You need to manually call becomeFirstResponder() on input bar.

All 3 comments

You need to manually call becomeFirstResponder() on input bar.

Thank you It has been solved.
what I did after passing it to ContainerView , In the MessageViewControllerClass added these lines only and its working now.

     override func viewDidAppear(_ animated: Bool)  {
      super.viewDidAppear(animated)
      self.becomeFirstResponder()
      messageInputBar.becomeFirstResponder()
    }

Thanks A-lot again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ichikmarev picture ichikmarev  路  4Comments

ChandraPrakashJangid picture ChandraPrakashJangid  路  3Comments

bilaalrashid picture bilaalrashid  路  3Comments

adri4silva picture adri4silva  路  4Comments

mlequeux picture mlequeux  路  3Comments