I have tried the swift example of JSQMessageViewController
inside iOS 11 simulator. Here is the result:screenshot
I have tried using safe area margin and modify the toolbar constraint but there is still no difference. It seems that the toolbar is outside UIWindow (UITextEffectsWindow instead). Is there any solution?
Guys I have figured it out! Just put the following code in the JSQMessagesInputToolbar.m. It seems that the inputtoolbar is placed in its own window, you need to access its window separately.
This answer is based on JSQMessagesViewController version 7.3.
Note: The code below contains some messy pragma directives to avoid compiler warnings. The code itself is actually quite simple once you see beyond the pragmas.
This seems to solve the problem while still allowing the toolbar to be moved when the software keyboard is presented. I added the following code in my JSQMessagesViewController subclass:
Edit: For Swift users, the following trick should let you call the private objc method:
Edit: The code that adjusts the contentInset of the collectionView is not called after this new constraint is added, so if the chat view contains more messages than fits the screen, the last message bubble is obscured by the input toolbar. I solved this by ensuring the insets are updated by adding the following code in
viewDidAppearviewDidLayoutSubviews:I am proposing a fixed fork based on the JSQ latest
develop
branch commit.It is using the
didMoveToWindow
solution. Not ideal but worth to try while waiting for Apple's answer aboutinputAccessoryView
's safe area layout guide attachment, or any other better fix.You can add this to your Podfile, replacing the previous JSQ line:
Just add an extension for JSQMessagesInputToolbar
I m having same problem. I m trying to solve it by adding the JSQMessageViewController as a child view on a viewController that has safe area set up.
Being MyJSQMessageViewController a subclass of JSQMessagesViewController:
Not ideal solution but at least you will have input toolbar inside iOS11 safe area... Bad news is that input toolbar wont be displayed on non safe areas so graphically wont be like a default toolbar (see image)
Found a solution without empty space below input toolbar on iPhoneX, the idea that not the whole toolbar
self
should be above the safe area, but only itsself.contentView
: