I have a simple UIInputViewController subclass with only two overridden methods. I use this input view controller as inputAccessoryViewController
on my UIViewController subclass which becomes first responder. I try to specify height of inputView by adding constraint as Apple documentation recommends.
Problem is that my constraint doesn't work and I get autolayout exception when my constraint is being added
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
...
(
"<NSLayoutConstraint:0x178aa1d0 V:[UIInputView:0x178a4ae0(0)]>",
"<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>
Which I think means that system already added a zero height constraint to the input view (because it is created with zero height). Now they conflict and autolayout breaks my constraint to fix the issue.
When I try to use it as inputViewController
of my view controller (just for test purposes), I get same exception but instead of zero height it is 216 px. It also breaks my constraint and the height remains default.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.inputView.translatesAutoresizingMaskIntoConstraints = NO;
self.inputView.backgroundColor = [UIColor redColor];
}
- (void)updateViewConstraints {
CGFloat _expandedHeight = 500;
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem:self.view
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:0.0
constant: _expandedHeight];
[self.inputView addConstraint: _heightConstraint];
[super updateViewConstraints];
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.view setNeedsUpdateConstraints];
}
As a result, I am not able to change input accessory view height. Has anyone succeed in it? Obviously, Apple documentation provides no help...