在storyboard中在viewcontroller中添加了scrollview,在scrollview上面添加了context view,在context view上面添加了view,view上面添加了label,均设置了约束,然后在viewdidload 中 print(self.bodyTextLabel.constraints.count)
结果显示是0,这是什么原因,还是说我哪里设置出现了问题?!
self.imageView.removeFromSuperview()
print(self.bodyTextLabel.constraints.count)
for constraint in self.bodyTextLabel.constraints {
if constraint.identifier == "LabelBottomToViewBottom" {
constraint.priority = 1000
}
}
在viewWillAppear也尝试了,发现打印出来constraints 还是0,整个项目,其他地方的view打印constrains打印都是0 。。。我也是醉了,莫非是storyboard设置什么出现了问题
context view 约束:
view 约束:
label的约束:
你在
viewWillAppear
中试试呢。viewDidLoad
中不要放置关于几何的代码,打印测试也是不准的。