This repository has been archived by the owner on Aug 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 270
Input view rendered incorrectly when NMessengerViewController
is inside UITabBarController
#122
Comments
Here is a fix of the func keyboardNotification(_ notification: Notification)
{
if let userInfo = (notification as NSNotification).userInfo
{
let endFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
let duration:TimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0
let animationCurveRawNSN = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIViewAnimationOptions().rawValue
let animationCurve:UIViewAnimationOptions = UIViewAnimationOptions(rawValue: animationCurveRaw)
let newKeyboardLocation = endFrame
let keyboardHeight = newKeyboardLocation?.size.height ?? 0
let inputBarHeight = inputBarView.frame.height
let isInsideTabBar = (nil != self.tabBarController)
let tabBarHeight = self.tabBarController?.tabBar.frame.size.height ?? 0
let isKeyboardOffScreen =
(newKeyboardLocation?.origin.y >= UIScreen.main.bounds.size.height)
let inputViewShiftOffsetY = keyboardHeight - tabBarHeight
if (isKeyboardOffScreen)
{
self.inputBarBottomSpacing.constant = 0
/*let bottomInset*/ _ = inputBarView.frame.height
self.isKeyboardIsShown = false
}
else
{
let isInputBarHasNoBottomSpacing = (self.inputBarBottomSpacing.constant == 0)
if (isInputBarHasNoBottomSpacing)
{
self.inputBarBottomSpacing.constant -= inputViewShiftOffsetY
/*let bottomInset*/ _ = inputViewShiftOffsetY + inputBarHeight
}
else
{
self.inputBarBottomSpacing.constant = 0
self.inputBarBottomSpacing.constant -= inputViewShiftOffsetY
/*let bottomInset*/ _ = inputViewShiftOffsetY + inputBarHeight
}
self.isKeyboardIsShown = true
}
let animationsBlock: () -> Swift.Void =
{
self.view.layoutIfNeeded()
if self.isKeyboardIsShown
{
self.messengerView.scrollToLastMessage(animated: true)
}
}
let noDelay: TimeInterval = 0
UIView.animate(withDuration: duration,
delay: noDelay,
options: animationCurve,
animations: animationsBlock,
completion: nil)
}
} |
dodikk
pushed a commit
to dodikk/NMessenger
that referenced
this issue
Apr 14, 2017
Fixed #123 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There should be no whitespace between the keyboard prompt and the input field.
The text was updated successfully, but these errors were encountered: