【发布时间】:2014-11-28 20:03:58
【问题描述】:
我有 2 个“姐妹视图”,一个位于另一个上方(说话的 Y)嵌入在同一个父视图中。
第一个是屏幕大小,下面是屏幕底部的大小。
在动画中,底部视图会升高并显示在屏幕上。
这个动画应该减少上视图的高度。
我想为此使用NSLayoutConstraint,但我找不到工作。
现在我有以下内容:
let constraintString : String = String(format: "V:[tranlucentView][buttonContainer(%lg)]", buttonHeight * countOfButtons)
let viewsDict:NSDictionary = ["tranlucentView" : self.translucentView, "buttonContainer" : self.buttonContainer]
var constraints : NSArray = NSLayoutConstraint.constraintsWithVisualFormat(constraintString, options: NSLayoutFormatOptions(0), metrics: nil, views: viewsDict)
self.view.addConstraints(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)
(
"<NSLayoutConstraint:0x198f6530 V:[UIView:0x198ef880]-(0)-[UIView:0x177b11e0]>",
"<NSLayoutConstraint:0x198f6600 V:[UIView:0x177b11e0(0)]>",
"<NSAutoresizingMaskLayoutConstraint:0x19f7f7f0 h=--& v=--& UIView:0x198ef880.midY == + 284>",
"<NSAutoresizingMaskLayoutConstraint:0x1983e4c0 h=--& v=--& V:[UIView:0x198ef880(568)]>",
"<NSAutoresizingMaskLayoutConstraint:0x19f7f260 h=--& v=--& UIView:0x177b11e0.midY == + 472>"
)
对我的问题有什么建议吗?
【问题讨论】:
标签: cocoa swift nslayoutconstraint