Custom Keyboard InputAccessoryView not visible in iOS 11

Ruchi picture Ruchi · Jun 15, 2017 · Viewed 11.1k times · Source

I have implemented Custom input accessory view it was working fine till iOS 10.3.1. But it's not visible in iOS 11 beta.

Have anyone experience this issue?

Answer

Jess picture Jess · Jul 4, 2017

The question you ask does not have much detail. But I had the same problem when using an inputAccessoryView and a custom inputView for the textfield.

And resolved this on iOS11 by setting the custom inputView's autoresizingMask to .flexibleHeight.

yourCustomInputView.autoresizingMask = .flexibleHeight

Hope this resolves the issue. If not maybe provide some more information?

Here is how I add the input accessory, incase this is of more help (as extension of textfield):

public extension UITextField {

public func addToolbarInputAccessoryView(barButtonItems: [UIBarButtonItem],
                                         textColour: UIColor,
                                         toolbarHeight: CGFloat = 44,
                                         backgroundColour: UIColor = .white) {

    let toolbar = UIToolbar()

    toolbar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: toolbarHeight)
    toolbar.items = barButtonItems
    toolbar.isTranslucent = false
    toolbar.barTintColor = backgroundColour
    toolbar.tintColor = textColour

    inputAccessoryView = toolbar
}

}

And then on the inputView (not the inputAccessoryView), I was using a date picker for example - just make sure that the date picker's autoresizing mask is set to flexible height.