我正在使用 PureLayout 创建约束
在cellForItemAtIndexPath
if (!_itemDetails){
_itemDetails = cell.itemDetails;
_itemDetailsConstraint = [_itemDetails autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:cell.imageView];
}
然后在scrollDidView
float scrollViewHeight = self.collectionView.frame.size.height;
float scrollOffset = self.collectionView.contentOffset.y;
if(_itemDetails){
if (scrollOffset + scrollViewHeight < CGRectGetMaxY(_frontImageView.frame)){
_itemDetailsConstraint.constant = CGRectGetMaxY(_frontImageView.frame) - (scrollOffset + scrollViewHeight);
}
else{
_itemDetailsConstraint.constant = 0;
}
}
[_itemDetails.superview layoutIfNeeded];
尽管在调试时,我可以看到约束的常量发生了变化,但视图不会更新到新位置。
我也试过
[self.view layoutIfNeeded]
和
[self.collectionView layoutIfNeeded]
如何更新视图的 ( _itemDetails
,它指向 a 中的视图CollectionViewCell
) 位置?