Closed little2s closed 9 years ago
Hi @little2s
Thanks for bringing this bug to my attention, and I'm glad you like the library! Your solution seems to work, but I'm hesitant to bring the screen dimensions into this because I'm worried about issues w/ the iPad as well as any other non-fullscreen situations.
I propose correcting the problem by replacing:
var keyboardFrame = (keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
With this:
var keyboardFrame = (keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
if let window = self.view.window {
keyboardFrame = window.convertRect(keyboardFrame, toView: self.view)
}
I also replaced this:
self.bottomChatInputConstraint.constant = -(CGRectGetHeight(self.view.bounds) - CGRectGetMinY(keyboardFrame))
With this:
var chatInputOffset = -(CGRectGetHeight(self.view.bounds) - CGRectGetMinY(keyboardFrame))
if chatInputOffset > 0 {
chatInputOffset = 0
}
self.bottomChatInputConstraint.constant = chatInputOffset
That way, no matter how the chatView is positioned, it will adjust properly for the keyboard. Let me know what you think.
I want to make sure you get credit for the bug, so feel free to make these changes instead and I'll merge it in. Otherwise, I can push it up myself. Thanks again for finding it!
Best,
Logan
[sorry about the temporary close, I clicked the wrong button]
Hi @LoganWright
Thanks so much for your reply! I had't consider other non-fullscreen situations on my way, your solution is better. I commit it as what you said.
I'm so sorry that replying you 2 days later for some other reasons.
Best,
Jerry
Looks good to me @little2s! Thanks for contributing!
Hello, Logan! Your SimpleChat is awesome, but I think there is a little problem here: When the navigationBar.translucent set to be
false
, the chatInput view will miss when keyboard is shown. For example, on iPhone 6 with iOS 8 on portrait, the view.bounds.height is 568 when navigationBar.translucent istrue
, but if navigationBar.translucent isfalse
, the height will be 504, so the self.bottomChatInputConstraint.constant here will be different, and chatInput view will under the keyboard, won't be shown. I tried to fix it on my forked branch, please help check it, thank you so much.