This answer is based on JSQMessagesViewController version 7.3.
Note. The code below contains some dirty pragma directives to avoid compiler warnings. The code itself is actually quite simple if you see outside the pragma.
This seems to solve the problem, while retaining the ability to move the toolbar when displaying the soft keyboard. I added the following code to my subclass of JSQMessagesViewController:
- (void)viewDidLoad { [...] // To keep the toolbar inside the safe area on iPhone X, we need to install a new constraint that has higher priority than the one // JSQMessagesViewController manipulates when adjusting for the keyboard. The `toolbarBottomLayoutGuide` is a private property in our // superclass, so it not straightforward to access it... if (@available(iOS 11.0, *)) {
Edit: For Swift users, the following trick should allow you to call the objc private method:
let constraint = perform(Selector(("toolbarBottomLayoutGuide"))).takeUnretainedValue() as! NSLayoutConstraint constraint.priority = 999
Edit:. Code that customizes the content. Entering the contents of the collection is not called after adding this new restriction, therefore, if the chat window contains more messages than fits the screen, the last message bubble is hidden using the input toolbar. I solved this by making sure the inserts are updated by adding the following code to viewDidAppear viewDidLayoutSubviews:
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector" [self performSelector:@selector(jsq_updateCollectionViewInsets)]; #pragma clang diagnostic pop
source share