I create a chat with uipageviewcontroller on root view, messagesCollectionView was present without the messageInputBar
MessageKit Version:
v.0.12
iOS Version(s):
iOS 10.0+
Swift Version:
Swift 4
Devices/Simulators:
iphone 6/7/8/X
Reproducible in ChatExample? (Yes/No):
Yes
I use the tchat conversation like example
I create a UIPageViewController with 2 pages, the first page is the conversation, the second is the settingsmessage. When I build, I saw all the mock message except, I didn't see the messageInputBar at the bottom of page

I will see the messageInputBar at the bottom
This is likely because you haven't correctly passed your root VC as a child. Can you check https://github.com/MessageKit/MessageKit/blob/master/Documentation/FAQs.md
Thanks @nathantannar4.
but I had an UIPageViewController like child, and a UIViewController like root, My UIpageViewController contains two views. this is my code
class MainViewController: UIViewController {
private var pageViewController: UIPageViewController?
private let viewControllers = [
ConversationViewController(),
SettingsViewController()
]
override func viewDidLoad() {
super.viewDidLoad()
pageViewController = UIPageViewController(
transitionStyle: .scroll,
navigationOrientation: .horizontal,
options: nil
)
self.addChildViewController(pageViewController!)
self.view.addSubview((pageViewController?.view)!)
pageViewController?.didMove(toParentViewController: self)
pageViewController?.dataSource = self
pageViewController?.setViewControllers(
[viewControllers[0]],
direction: .forward,
animated: true,
completion: nil
)
}
}
extension MainViewController: UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController,
viewControllerBefore viewController: UIViewController) -> UIViewController? {
let currentIndex = viewControllers.index(of: viewController)
if currentIndex == 0 {
return nil
}
let ctrl = viewControllers[currentIndex! - 1]
return ctrl
}
func pageViewController(_ pageViewController: UIPageViewController,
viewControllerAfter viewController: UIViewController) -> UIViewController? {
let currentIndex = viewControllers.index(of: viewController)
if currentIndex == (viewControllers.count - 1) {
return nil
}
let ctrl = viewControllers[currentIndex! + 1]
return ctrl
}
}
Quite same issue #501
I don't even see the MessagesViewController subclass in your code 馃 You likely need to call self.becomeFirstResponder() to solve this. Feel free to reopen if it isn't solved
I have the same issue here. I am following the FAQs.
import UIKit
import MessageKit
class ConversationsViewController: UIViewController {
var chatViewController: MessagesViewController!
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func viewDidLoad() {
super.viewDidLoad()
// Implement the MessagesViewController
self.chatViewController = MessagesViewController()
addChildViewController(self.chatViewController)
self.chatViewController.view.frame = CGRect(x: 250, y: 142, width: 776, height: 626)
self.view.addSubview(self.chatViewController.view)
self.chatViewController.didMove(toParentViewController:self)
self.becomeFirstResponder()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
When I just do the following, the MessageInputBar appears.
import UIKit
import MessageKit
class ConversationsViewController: MessagesViewController {
...
}
Am I missing something? Thank you for your help!
@cubytz try chatViewController.becomeFirstResponder()
Sent with GitHawk
Anyone having this issue on the 2.0 beta?
I have a UIPageViewController that contains two controllers; one of which is a subclass of MessagesViewContoller
The UIPageViewController is defined as follows:
class MyPageViewController: UIPageViewController {
lazy var controllers: [UIViewController] = {
let photosController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MyPhotosViewController")
let messagesController:UIViewController = MyMessagesViewController()
return [photosController, messagesController]
}()
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.dataSource = self
setViewControllers([controllers[0]], direction: .forward, animated: true, completion: nil)
}
}
My MessagesViewController subclass is defined as:
class MyMessagesViewController: MessagesViewController {
var messages:[MyMessage] = [ ]
override func viewDidLoad() {
super.viewDidLoad()
messagesCollectionView.messagesDataSource = self
messagesCollectionView.messagesLayoutDelegate = self
messagesCollectionView.messagesDisplayDelegate = self
messagesCollectionView.messageCellDelegate = self
messageInputBar.delegate = self
...
}
override func viewDidAppear(_ animated: Bool) {
self.becomeFirstResponder()
}
I'm adding self.becomeFirstResponder() in viewDidAppear but the messageInputBar is still hidden
Any help is appreciated!
Make sure you are configuring your page VC correctly. Have you checked if viewDidAppear is even being called?
Sent with GitHawk
@nathantannar4
Thanks for the response!
Yes, viewDidAppear is being called. I also added self.becomeFirstResponder() to viewWillAppear and I noticed that the messageInputBar will show as I'm in the middle of transitioning to the page that contains the MessagesViewController but once the transition completes the messageInputBar disappears again.
This made me think I could leverage the UIPageViewController delegate function
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)
and set the MessagesViewController to be the first responder in there but still no luck
@michaelonjack have you managed to resolve the problem with UIPageViewController and absent MessageInputBar? I have encountered the same issue
Most helpful comment
Quite same issue #501