Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x2814699c0 "UIImageView:0x10ac6f2a0.top"> and <NSLayoutYAxisAnchor:0x28144ad00 "UICollectionView:0x10c176c00.top"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'
将header 中的 imageview 跟viewcontroller 中的view 进行绑定会崩溃
NSLayoutConstraint *layout = [self.backImage.topAnchor constraintEqualToAnchor:collectionView.topAnchor]; [NSLayoutConstraint activateConstraints:@[layout]];
但是使用普通的UICollectionViewFlowLayout 却没有问题
错误信息:
Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x2814699c0 "UIImageView:0x10ac6f2a0.top"> and <NSLayoutYAxisAnchor:0x28144ad00 "UICollectionView:0x10c176c00.top"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'