Open Goles opened 9 years ago
Just do a typecast to UICollectionViewLayoutAttributes where it complains about indexPath:
Example row 67:
Replace
return [itemsIndexPathsInVisibleRectSet containsObject:
[[[behaviour items] firstObject] indexPath]] == NO;
With the following
return [itemsIndexPathsInVisibleRectSet containsObject:
[((UICollectionViewLayoutAttributes *)[[behaviour items] firstObject]) indexPath]] == NO;
Works for me. Should this issue be closed?
There's a pull request open since June 10 fixing this issue https://github.com/yairsz/UICollectionView-Spring-Demo/commit/1a8e850058fe314ad52eb347c3376a77facea702
I think it is caused by the new generic feature
// Step 1: Remove any behaviours that are no longer visible.
NSArray *noLongerVisibleBehaviours = [self.dynamicAnimator.behaviors filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UIAttachmentBehavior *behaviour, NSDictionary *bindings) {
UICollectionViewLayoutAttributes *layoutAttr =
(UICollectionViewLayoutAttributes *)(behaviour.items.firstObject);
return [itemsIndexPathsInVisibleRectSet containsObject:layoutAttr.indexPath] == NO;
}]];
[noLongerVisibleBehaviours enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
[self.dynamicAnimator removeBehavior:obj];
UICollectionViewLayoutAttributes *layoutAttr =
(UICollectionViewLayoutAttributes *)(((UIAttachmentBehavior *)obj).items.firstObject);
NSIndexPath *indexPathNeedToRemove = layoutAttr.indexPath;
[self.visibleIndexPathsSet removeObject:indexPathNeedToRemove];
[self.visibleHeaderAndFooterSet removeObject:indexPathNeedToRemove];
}];
Just for the record,
UIAttachmentBehavior
does not respond to indexPath.When trying to build I'm getting:
"No known instance method for selector
indexPath
" compiler errors.(maybe you know a way to go around this issue)