我想将 UIPickerView 隐藏在屏幕下方,在本例中为 3.5 英寸显示屏。在了解了约束值之后,我终于知道我应该输入什么数字了NSLayoutAttributeTop
。
这是我的完整代码:
NSLayoutConstraint *constraint = [NSLayoutConstraint
constraintWithItem:_pickerView
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:416.f];
[self.view addConstraint:constraint];
当我遇到我的 iDevice 时,它会像我预期的那样工作,除了......调试器控制台......它给了我这个消息:
2013-09-19 12:34:01.850 Constrain2[3546:c07] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x75490d0 h=--& v=--& V:[UIView:0x715a2f0(416)]>",
"<NSLayoutConstraint:0x7159950 V:[UIPickerView:0x715a030(216)]>",
"<NSLayoutConstraint:0x71597c0 V:|-(416)-[UIPickerView:0x715a030] (Names: '|':UIView:0x715a2f0 )>",
"<NSLayoutConstraint:0x715a7a0 UIPickerView:0x715a030.bottom == UIView:0x715a2f0.bottom>"
)
当我将常量值更改为取自 416(superview)-216(uipickerview)的 = 200.f 时,调试器控制台很清晰。那里没有消息。
是错误消息还是警告?可以忽略吗?是否可以隐藏屏幕下方的 UIPickerView 而不会在调试器控制台上显示该消息?
当 UIPickerView 正确放置在其位置时,似乎不会出现该消息。这是恒定的:200.f
谢谢你。