3

I am using MessageKit 3.0.0-swift5 branch for chats. Clicking on the message, I am presenting the ViewController. When Viewcontroller is dismissed, I am not able to access InputBar.

Has anybody come across this issue?

Check the video here.

Code:

// MessageCellDelegate

func didTapMessage(in cell: MessageCollectionViewCell) { 
     self.showFileInBrowser(withTitle: "", url: fileURL)
}

func showFileInBrowser(withTitle title: String? = nil,  url: URL) {
     self.fileBrowser = FileBrowserViewController(title: title, url: url)
     let navigation = BaseNavigationController(rootViewController: fileBrowser!)
     self.present(navigation, animated: true, completion: nil)
}

// FileBrowserViewController

@objc func closeButtonTapped() {
    self.dismiss(animated: true, completion: nil)
}

I am also using IQKeyboardManager, but the below solution is not working.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    IQKeyboardManager.shared().isEnabled = false
}

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    IQKeyboardManager.shared().isEnabled = true
}
rushisangani
  • 3,195
  • 2
  • 14
  • 18

3 Answers3

1

I had the same issue in my application, which is using just InputBarViewController (in some reasons I had to implement my own chat, not using MessageKit).

So, this issue is very easy to reproduce if you are trying to show some modal view controller not from current controller, or even moving first responder focus to another UITextField within current VC (e.g. search field). For me working solution is just call becomeFirstResponder on current view controller instance just after resigning control from search field or inside viewDidAppear (or in some other place where you can be sure, chat UI is visible again).

P.S. I also faced this issue when UIContextMenu (long touch in cell) was dismissed. Solution was pretty the same.

agoncharov
  • 822
  • 1
  • 6
  • 15
0

I think that you have to before present the next ViewController disable Keyboard by TextView.resignFirstResponder() Because the problem begins while ViewController is Presenting

  • If you still have problem let me know to find solution – Alireza Namazi Oct 04 '19 at 16:17
  • dismissing keyboard is not working. This is very random behavior. – rushisangani Oct 04 '19 at 17:09
  • I am using JSQ, but same issue. InputToolBar disappears after presenting native Camera app. Calling resignFirstResponder does nothing as the ViewController resigns first responder as a new ViewController is presented and at the same time inputToolBar gets dismissed. – coolcool1994 Mar 16 '20 at 08:17
0

I too facing that issue before, but i tried to to present nextViewController as by adding the following code. hope it will work.

 nextViewController.modalPresentationStyle = .overCurrentContext
 nextViewController.modalTransitionStyle = .coverVertical
Suresh Mopidevi
  • 919
  • 3
  • 9
  • 24