I have a simple UIInputViewController subclass with only two overridden methods. I use this input view controller as inputAccessoryViewController
on my UIViewContro
I don't know if this is the issue, but the problem may come from the 0.0 multiplier you are setting on _heightConstraint. Try to change it to 1.0.
It would look like this:
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem:self.view
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant: _expandedHeight];
Hope this helps!
Since iOS 9.0 this can be solved with inputView.allowsSelfSizing = YES;
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.
I did it in Swift. hope this helps you.
override func viewDidAppear(animated: Bool) {
let heightConstraint = NSLayoutConstraint(
item:self.view,
attribute:NSLayoutAttribute.Height,
relatedBy:NSLayoutRelation.Equal,
toItem:nil,
attribute:NSLayoutAttribute.NotAnAttribute,
multiplier:0.0,
constant:100)
self.view.addConstraint(heightConstraint)
}