Custom Keyboard InputAccessoryView not visible in iOS 11

前端 未结 7 1957
攒了一身酷
攒了一身酷 2021-02-18 21:30

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?

7条回答
  •  梦谈多话
    2021-02-18 22:03

    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.

提交回复
热议问题