0
func keyboardWillShow(notification: NSNotification) {
    let userInfo = notification.userInfo as NSDictionary!
    let frameNew = (userInfo[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
    let insetNewBottom = tableView.convertRect(frameNew, fromView: nil).height
    let insetOld = tableView.contentInset
    let insetChange = insetNewBottom - insetOld.bottom
    let overflow = tableView.contentSize.height - (tableView.frame.height-insetOld.top-insetOld.bottom)

    let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as NSNumber).doubleValue
    let animations: (() -> Void) = {
        if !(self.tableView.tracking || self.tableView.decelerating) {
            // Move content with keyboard
            if overflow > 0 {                   // scrollable before
                self.tableView.contentOffset.y += insetChange
                if self.tableView.contentOffset.y < -insetOld.top {
                    self.tableView.contentOffset.y = -insetOld.top
                }
            } else if insetChange > -overflow { // scrollable after
                self.tableView.contentOffset.y += insetChange + overflow
            }
        }
    }
    if duration > 0 {
        let options = UIViewAnimationOptions(UInt((userInfo[UIKeyboardAnimationCurveUserInfoKey] as NSNumber).integerValue << 16)) // http://stackoverflow.com/a/18873820/242933
        UIView.animateWithDuration(duration, delay: 0, options: options, animations: animations, completion: nil)
    } else {
        animations()
    }
}

I have a toolbar, and when the textview in the toolbar is selected, the keyboard appears under it. The toolbar then slides up, but just to above the keyboard, but it still hides beneath the new suggestions feature above the keyboard in one of the recent iOS updates.

How do I make sure that the toolbar stays above the word suggestions?

user83039
  • 3,047
  • 5
  • 19
  • 31
  • Why not use an accessory view? – soulshined Dec 28 '14 at 04:03
  • Because this: http://stackoverflow.com/questions/27664129/constraint-controls-greyed-out-in-xcode-pinning-toolbar-to-bottom/27664304#27664304 – user83039 Dec 28 '14 at 04:17
  • 1
    I don't understand. That question is for table views. You just want a tool bar on top of the keyboard. That's called input accessory view. It handles all animations for you and you can put whatever you want in to almost https://www.google.com/search?q=ios+inputaccessoryview&ie=UTF-8&oe=UTF-8&hl=en&client=safari – soulshined Dec 28 '14 at 04:24

1 Answers1

1

You can either hide the words Suggestions by TEXTVIEW.autocorrectionType = UITextAutocorrectionType.No

Or

Use input accessory view as follows: TEXTVIEW.inputAccessoryView = your custom view ; so you need not know the height of the suggestions toolbar , create your view and the TEXTVIEW.inputAccessoryView will automatically place it above the suggestions

Amisha
  • 159
  • 1
  • 8