InputAccessoryView not showing

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

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

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

Here's an example of some of the things I've 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 also looked at this question on SO: Swift inputAccessoryView override bug This shows that it works for the user ... suffice it to say that I have not been able to display anything on the screen yet.

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

+3


source to share


2 answers


It turns out I'm missing:

self.becomeFirstResponder()

      



Now everything appears.

+2


source


For those with this problem, I had to add this line to the UIView subclass returned inputAccessoryView

:



self.autoresizingMask = .flexibleHeight

      

0


source







All Articles