swiftuikeyboardinputaccessoryview

inputAccessoryView not displaying


I am trying to create a messaging interface, that is similar to the iOS messaging app. The part I am struggling with is overriding inputAccessoryView (on the view controller) is having no effect for me.

If you look at the link below, it shows a brief potential solution, without going into specifics.

The following link explains my question better than I could: http://robots.thoughtbot.com/input-accessorizing-uiviewcontroller

Here is an example of some things I have tried:

override func canBecomeFirstResponder() -> Bool {
    return true
}

override var inputAccessoryView: UIView! {
    return self.keyboardToolbar // Which is of type UIToolbar
    // I have also tried creating a toolbar here and returning it instead of the above approach, with no luck
}

I have also seen this question on SO: Swift inputAccessoryView override bug That shows it working for the user... suffice to say i have not managed to get anything to show up on the screen at present.

What am i doing wrong? Does anyone have a working snippet i could try?


Solution

  • Turns out i was missing a:

    self.becomeFirstResponder()
    

    Now everything shows up.