Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios I';为了使用约束将UIPickerView隐藏在屏幕下方,我可以忽略此调试器消息吗?_Ios_Objective C - Fatal编程技术网

Ios I';为了使用约束将UIPickerView隐藏在屏幕下方,我可以忽略此调试器消息吗?

Ios I';为了使用约束将UIPickerView隐藏在屏幕下方,我可以忽略此调试器消息吗?,ios,objective-c,Ios,Objective C,我想将UIPickerView隐藏在屏幕下方,在本例中为3.5英寸显示屏。在了解了约束值之后,我终于知道应该为nslayoutatributetop输入什么数字 以下是我的完整代码: NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:_pickerView attrib

我想将UIPickerView隐藏在屏幕下方,在本例中为3.5英寸显示屏。在了解了约束值之后,我终于知道应该为
nslayoutatributetop
输入什么数字

以下是我的完整代码:

NSLayoutConstraint *constraint = [NSLayoutConstraint
                                  constraintWithItem:_pickerView
                                  attribute:NSLayoutAttributeTop
                                  relatedBy:NSLayoutRelationEqual
                                  toItem:self.view
                                  attribute:NSLayoutAttributeTop
                                  multiplier:1.0f
                                  constant:416.f];

[self.view addConstraint:constraint];
当我遇到我的创意时,它就像我预期的那样工作,除了。。。调试器控制台。。它给了我这样一个信息:

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>"
)
2013-09-19 12:34:01.850约束2[3546:c07]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
"",
""
)
当我将常量值更改为=200.f(取自416(superview)-216(uipickerview)时,调试器控制台被清除。没有消息

是错误信息还是警告?可以忽略吗?是否可以将UIPickerView隐藏在屏幕下方,而不在调试器控制台上显示该消息

当UIPickerView正确放置在其位置时,消息似乎不会出现。这是常数:200华氏度

谢谢。

添加行

_pickerView.translatesAutoresizingMaskIntoConstraints = NO;

在添加约束之前。

不,您不应该忽略这一点——系统将尝试通过删除约束来修复它,但我不知道它是否总是删除相同的约束,并给出您想要的结果。您添加的约束似乎与您已有的约束冲突(我在回答您之前的问题时对同一问题进行了评论)。当您在代码中添加新约束时,您需要删除在IB中创建的一个(或多个)与之冲突的约束。但是,要执行您试图执行的操作,您甚至不应该添加新的约束,您应该修改在IB中创建的约束。从错误消息看,您似乎有一个从选择器底部到其superview底部的约束(长度为0)。您应该为该约束创建一个IBOutlet(例如,我们将其称为bottomCon),然后在代码中修改其常量参数:

self.bottomCon.constant = -216; 

在任何情况下,如果要对靠近屏幕底部的视图进行约束,则应将约束设置为底部,而不是像在问题中那样设置为顶部。如果您将常数设置为顶部,则在不同的屏幕大小或方向上将不正确。

谢谢您的回答,兄弟。。但我仍然在调试器控制台上看到相同的消息…谢谢你的回答,教授。这让我现在明白了约束的含义。。。我真的很感激。。。