Unable to change UIInputView height

前端 未结 4 2058
北荒
北荒 2021-02-14 08:55

I have a simple UIInputViewController subclass with only two overridden methods. I use this input view controller as inputAccessoryViewController on my UIViewContro

4条回答
  •  走了就别回头了
    2021-02-14 09:44

    When you make a view the input accessory view of a UITextView, as soon as the text view becomes first responder, a height constraint is added automatically set to whatever was sent as the frame height. For example:

    let inputView = UIInputView(frame: CGRectMake(0, 0, view.bounds.width, 200), 
        inputViewStyle: .Default)
    someTextView.inputAccessoryView = inputView
    someTextView.becomeFirstResponder()
    assert((inputView.constraints().last as NSLayoutConstraint).constant == 200)
    

    You can modify this constraint after the fact.

提交回复
热议问题