我设置了一个带约束的界面,包括菜单栏,集合视图,后跟标签,最后是表格视图。我试图通过出口将集合视图的宽度更改为宽度约束。但是,当我进行此更改时,集合视图似乎向上移动,我收到冲突错误。该错误表明:
之间存在冲突"<_UILayoutSupportConstraint:0x7ff61a519020 V:[_UILayoutGuide:0x7ff61a564eb0(64)]>",
"<_UILayoutSupportConstraint:0x7ff61a555a00 V:|-(0)-[_UILayoutGuide:0x7ff61a564eb0] (Names: '|':UIView:0x7ff61a5620c0 )>",
"<NSLayoutConstraint:0x7ff61a5665e0 V:[_UILayoutGuide:0x7ff61a564eb0]-(0)-[UICollectionView:0x7ff61b05ea00]>",
"<NSAutoresizingMaskLayoutConstraint:0x7ff61a4e1630 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x7ff61a5620c0] (Names: '|':UIViewControllerWrapperView:0x7ff61a70c4e0 )>"
被破坏的约束是
<NSLayoutConstraint:0x7ff61a5665e0 V:[_UILayoutGuide:0x7ff61a564eb0]-(0)-[UICollectionView:0x7ff61b05ea00]>
造成这种情况的原因是什么?
答案 0 :(得分:0)
我发现错误的原因是我试图在viewDidLoad中调用layoutIfNeeded。