创建视图无法同时满足约束条件时,图幅为零
init(){
super.init(frame: .zero)
}
创建视图我想设置我的子视图
func setViews(){
self.addSubview(labelView)
self.addConstraintsWithFormat("V:|-10-[v0]-10-|", views: labelView)
self.addConstraintsWithFormat("H:|-10-[v0]-10-|", views: labelView)
}
一切正常后,但我已经警告说,
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:0x7f87ea8e6520 V:|-(10)-[BIPartners.labelView:0x7f87eb56be20] (Names: '|':BIPartners.labelView:0x7f87eb56a320)>",
"<NSLayoutConstraint:0x7f87ea8e6af0 V:[BIPartners.labelView:0x7f87eb56be20]-(10)-| (Names: '|':BIPartners.labelView:0x7f87eb56a320)>",
"<NSLayoutConstraint:0x7f87e868bdc0 '_UITemporaryLayoutHeight' V:[BIPartners.labelView:0x7f87eb56a320(0)]>"
)
我知道这个问题是当我将帧设置为零。我将帧设置为零,并将垂直边距设置为10.我应该如何解决此问题?
你和VFL结婚了吗?在堆栈视图或其他内容中执行此操作可能会更容易,并隐藏/取消隐藏所需的元素,这样您就不会对约束进行记录。 – Adrian