自定义键盘InputAccessoryView在iOS 11中不可见 [英] Custom Keyboard InputAccessoryView not visible in iOS 11
问题描述
我已经实现了自定义输入附件视图,该视图在iOS 10.3.1之前都可以正常工作.但这在iOS 11 Beta中不可见.
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.
有人遇到这个问题吗?
推荐答案
您提出的问题没有太多细节.但是,在将inputAccessoryView和自定义inputView用于文本字段时,我遇到了同样的问题.
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.
并在iOS11上通过将自定义inputView的autoresizingMask设置为.flexibleHeight来解决此问题.
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
}
}
然后在 inputView (不是 inputAccessoryView )上,例如,我使用的是日期选择器-只要确保将日期选择器的自动调整大小掩码设置为可更改即可高度.
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.
这篇关于自定义键盘InputAccessoryView在iOS 11中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!