相关疑难解决方法(0)

无法更改UIInputView高度

我有一个简单的UIInputViewController子类,只有两个重写的方法.我inputAccessoryViewController在我的UIViewController子类上使用此输入视图控制器,它成为第一响应者.我尝试通过添加约束来指定inputView的高度,如Apple文档所建议的那样.问题是我的约束不起作用,并且在添加约束时我得到autolayout异常

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)]>
Run Code Online (Sandbox Code Playgroud)

我认为这意味着系统已经为输入视图添加了零高度约束(因为它创建的高度为零).现在他们冲突和自动布局打破我的约束来解决问题.

当我尝试使用它作为inputViewController我的视图控制器(仅用于测试目的)时,我得到相同的异常,但不是零高度,它是216 px.它也打破了我的约束,高度保持默认.

- (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 = …
Run Code Online (Sandbox Code Playgroud)

objective-c ios autolayout ios8 uiinputviewcontroller

10
推荐指数
1
解决办法
2541
查看次数