loganwright/SimpleChat

Bug when embedded in Tabbar

Closed this issue · 1 comments

First of all this is great work ! I block on one issue, when its embedded in tabbar controller, text field is masked by the bottom bar. It have to be linked to the way you use constraints but i can't find a way to fix it. Any clue or solution =) ?
(edit) I managed to make it show on top of bar if there one but when i dismiss the key bord all disappear under the bar

(edit) found a solution : (IOS8 but easy to adapt for IOS7)

private func chatInputConstraints() -> [NSLayoutConstraint] {
self.bottomChatInputConstraint = NSLayoutConstraint(item: chatInput, attribute: .Bottom, relatedBy: .Equal, toItem: self.bottomLayoutGuide, attribute: .Top, multiplier: 1.0, constant: 0)
let leftConstraint = NSLayoutConstraint(item: chatInput, attribute: .Left, relatedBy: .Equal, toItem: self.view, attribute: .Left, multiplier: 1.0, constant: 0.0)
let rightConstraint = NSLayoutConstraint(item: chatInput, attribute: .Right, relatedBy: .Equal, toItem: self.view, attribute: .Right, multiplier: 1.0, constant: 0.0)
return [leftConstraint, self.bottomChatInputConstraint, rightConstraint]
}

func keyboardWillChangeFrame(note: NSNotification)
{
boardAnimationDetail = note.userInfo!
let duration = keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] as! NSTimeInterval
var keyboardFrame = (keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
if let window = self.view.window {
keyboardFrame = window.convertRect(keyboardFrame, toView: self.view)
}
let animationCurve = keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] as! UInt

    self.tableView.scrollEnabled = false
    self.tableView.decelerationRate = UIScrollViewDecelerationRateFast
    self.view.layoutIfNeeded()
    var chatInputOffset: CGFloat
    chatInputOffset = 0;
    if self.bottomChatInputConstraint.constant == 0
    {
        chatInputOffset = (self.bottomLayoutGuide.length - keyboardFrame.height)
    }
    self.bottomChatInputConstraint.constant = chatInputOffset
    self.view.layoutIfNeeded()
    UIView.animateWithDuration(duration, delay: 0.0, options: UIViewAnimationOptions(animationCurve), animations: { () -> Void in
        self.view.layoutIfNeeded()
        self.scrollToBottom()
        }, completion: {(finished) -> () in
            self.tableView.scrollEnabled = true
            self.tableView.decelerationRate = UIScrollViewDecelerationRateNormal
    })
}

sorry i don't have time to fork but after review you could integrate it

@Alex293 - Made a few small changes to your code, but should work w/ tabbar now.