-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageInputBar UI problem when sending message or scrolling #503
Comments
Hi @zoufishanmehdi is this reproducible in the chat example? What is your code for when a message is sent Sent with GitHawk |
Hi @nathantannar4 it didn't happen when I was playing around with chat example. Below you can see the code for sending a message: `extension ChatVC {
}` |
Are you using Swift 3? Sent with GitHawk |
Also I thought the issue was for when you paste an image in the bar, where are you handling images Sent with GitHawk |
@nathantannar4 I'm using Swift 4. I don't paste the image in the bar. When the user presses camera icon in the left stackview of message input bar, they can select an image or take a picture. For that, I'm using TGCameraViewController library. After they press use this, that's when I make a post request to save the image. Below you can see methods from TGCameraViewController for handling images: `func cameraDidTakePhoto(_ image: UIImage!) {
Also, the problem tends to happen after I send some sort of message (either image or text). It also happens sometimes when I'm scrolling. |
Are you using some kind of custom container controller? Sent with GitHawk |
No, not using a custom container controller, just a View Controller. For image styling, I'm using a custom bubble. `func messageStyle(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageStyle {
|
This problem is still occurring. Are there any updates? Would really appreciate your input! |
Hi @zoufishanmehdi we can't reproduce this in the example. Can you please give us a detailed list on how you reproduce it and if possible also attach the code you use in your VC as I expect this is a client side issue. Sent with GitHawk |
@nathantannar4 What's your email address so I can send you the code for my VC and steps to reproduce it? |
I just emailed you the information above. Let me know if you need anything else. Thank you! |
I think is your issue |
That makes sense. What's the best way of dealing with that? I'm guessing you either need to remove it from superview or change the frame of the tab bar. |
Change the frame. I know there are a lot of samples on stack overflow Sent with GitHawk |
Closing as it’s a client side issue Sent with GitHawk |
Thank you, will look into it. Just as a side note- this problem wasn't happening when I was using JSQMessages and I was hiding the tab bar in viewWillAppear similar to the way I do it now. |
Hey @zoufishanmehdi, we do have quite a few differences between JSQMessagesViewController and MessageKit. The biggest difference is the |
@SD10 I see. This problem is still occurring even when I change the frame of the tab bar. |
@zoufishanmehdi I'm sorry but in this case it is likely due to some other client side bug in your code. I'd recommend starting from our example project and working to what you need. When reviewing your code there was a lot that looked unused or scattered which makes the problem harder to isolate. Sent with GitHawk |
Even I had the same issue, not only did my input bar start floating, but also the growth of the bar started jumping and went out of frame. So, couldn't pin point the issue, tried removing the |
@nathantannar4 & @SD10, I was able to reproduce this issue (or at least a similar one). When one of if requiredInputTextViewHeight != inputTextView.bounds.height {
// Prevent un-needed content size invalidation
invalidateIntrinsicContentSize()
} the expression will always evaluate to false because the To workaround this issue, I implemented the func messageInputBar(_ inputBar: MessageInputBar, textViewTextDidChangeTo text: String) {
let totalPadding = inputBar.padding.top
+ inputBar.padding.bottom
+ inputBar.topStackViewPadding.top
+ inputBar.textViewPadding.top
+ inputBar.textViewPadding.bottom
// Fix for MessageKit layout bug when MessageInputBar.textViewDidChange() disables the send button and the inputTextView resizes early preventing the MessageInputBar intrinsic content size from getting updated.
if(text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&
inputBar.requiredInputTextViewHeight == inputBar.inputTextView.bounds.height &&
inputBar.intrinsicContentSize.height - inputBar.inputTextView.bounds.height > totalPadding) {
inputBar.invalidateIntrinsicContentSize()
}
} |
Wanna make a PR for:
to
The purpose was to only help improve the performance |
If you want to keep the performance improvements I have two ideas: 1: Add an observer to the InputStackView's size, intrinsicContentSize, or some other property of your choosing which performs the conditional check. This should probably be in addition to the conditional check in 2: Replace let verticalPadding = inputBar.padding.top
+ inputBar.padding.bottom
+ inputBar.topStackViewPadding.top
+ inputBar.textViewPadding.top
+ inputBar.textViewPadding.bottom
return inputBar.intrinsicContentSize.height - verticalPadding What do you think? |
If you are using IQKeyboardManager framework. it will be affected this situation. You can add this code
|
I haven't tested it, but option 3 might be to move the check to happen before iterating on each /// Enables/Disables the sendButton based on the InputTextView's text being empty
/// Calls each items `textViewDidChangeAction` method
/// Calls the delegates `textViewTextDidChangeTo` method
/// Invalidates the intrinsicContentSize
@objc
open func textViewDidChange() {
let trimmedText = inputTextView.text.trimmingCharacters(in: .whitespacesAndNewlines)
if shouldManageSendButtonEnabledState {
sendButton.isEnabled = !trimmedText.isEmpty || inputTextView.images.count > 0
}
inputTextView.placeholderLabel.isHidden = !inputTextView.text.isEmpty
// Moved to here
let shouldInvalidateIntrinsicContentSize = requiredInputTextViewHeight != inputTextView.bounds.height
items.forEach { $0.textViewDidChangeAction(with: inputTextView) }
delegate?.messageInputBar(self, textViewTextDidChangeTo: trimmedText)
// Moved above
if shouldInvalidateIntrinsicContentSize {
// Prevent un-needed content size invalidation
invalidateIntrinsicContentSize()
}
} |
@nathantannar4 Have any input here? Can't tell if this is a client issue or MessageKit issue |
Even i am facing the same problem. If press return on keyboard or scroll when keyboard is open, the input textview shifts up. |
Are you using the IQKeyboardManager? |
No. I am using the default keyboard. |
This has still been something I cannot reproduce in the Example, are you doing anything else? Using any custom controller containers? Tab bar controllers? |
The roortViewController of my application is TabBarController but this
screen do not have any tab bar.
…On Sat, May 12, 2018 at 4:22 AM, Nathan Tannar ***@***.***> wrote:
This has still been something I cannot reproduce in the Example, are you
doing anything else? Using any custom controller containers? Tab bar
controllers?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#503 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AH4jc5FpiD77j0vibZtCGweH4HZYpniAks5txhY_gaJpZM4R1_vZ>
.
--
Thanks & Regards
Shruti Mittal
|
The roortViewController of my application is TabBarController but this screen do not have any tab bar. |
@Shrutimittal91 See #399 #85 |
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has been auto-closed because there hasn't been any activity for at least 21 days. However, we really appreciate your contribution, so thank you for that! 🙏 Also, feel free to open a new issue if you still experience this problem 👍. |
General Information
MessageKit Version:
0.13.1
iOS Version(s):
iOS 11.2.2
Swift Version:
Swift 4
Devices/Simulators:
iPhone 7
Reproducible in ChatExample? (Yes/No):
No
What happened?
What did you expect to happen?
I expect the message input bar to stick to the bottom when I'm scrolling or sending messages (images or text) and not have message bubbles appear above and below the message input bar.
The text was updated successfully, but these errors were encountered: