I am using PureLayout to create the constraints
in cellForItemAtIndexPath
if (!_itemDetails){
_itemDetails = cell.itemDetails;
_itemDetailsConstraint = [_itemDetails autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:cell.imageView];
}
and then in 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];
eventhough while debugging, I can see that the constraint's constant changed, the view doesn't update to the new location.
I also tried
[self.view layoutIfNeeded]
and
[self.collectionView layoutIfNeeded]
How can I update the view's (_itemDetails
, which point to a view in a CollectionViewCell
) location?
if your contraints is create or update in the collection:cellForItemAtIndexPath:,you can reload all cell.