Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit df9f433

Browse files
author
Scott Goodson
committed
Prevent calling unsupported UICollectionViewDelegate methods (supplementary view appearance)
1 parent 0636ec4 commit df9f433

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

AsyncDisplayKit/ASCellNode.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ - (instancetype)initWithViewControllerBlock:(ASDisplayNodeViewControllerBlock)vi
6363
return self;
6464
}
6565

66-
//- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
67-
//{
68-
// _viewControllerNode.frame = (CGRect){{0,0}, constrainedSize.max};
69-
// NSLog(@"%f %f", constrainedSize.max.width, constrainedSize.max.height);
70-
// return [super layoutSpecThatFits:constrainedSize];
71-
//}
72-
7366
- (void)layout
7467
{
7568
[super layout];

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,16 @@ - (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(N
944944
ASDisplayNodeAssert(![self.asyncDataSource respondsToSelector:_cmd], @"%@ is not supported by ASCollectionView - please remove or disable this data source method.", NSStringFromSelector(_cmd));
945945
}
946946

947+
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
948+
{
949+
ASDisplayNodeAssert(![self.asyncDataSource respondsToSelector:_cmd], @"%@ is not supported by ASCollectionView - please remove or disable this delegate method.", NSStringFromSelector(_cmd));
950+
}
951+
952+
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)view forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
953+
{
954+
ASDisplayNodeAssert(![self.asyncDataSource respondsToSelector:_cmd], @"%@ is not supported by ASCollectionView - please remove or disable this delegate method.", NSStringFromSelector(_cmd));
955+
}
956+
947957
#endif
948958

949959
@end

AsyncDisplayKit/Details/ASDelegateProxy.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ - (BOOL)interceptsSelector:(SEL)selector
5858

5959
// intercepted due to not being supported by ASCollectionView (prevent bugs caused by usage)
6060
selector == @selector(collectionView:canMoveItemAtIndexPath:) ||
61-
selector == @selector(collectionView:moveItemAtIndexPath:toIndexPath:)
61+
selector == @selector(collectionView:moveItemAtIndexPath:toIndexPath:) ||
62+
selector == @selector(collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath:) ||
63+
selector == @selector(collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:)
6264
);
6365
}
6466

examples/CustomCollectionView/Sample/ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ - (instancetype)init
5454

5555
_layoutInspector = [[MosaicCollectionViewLayoutInspector alloc] init];
5656

57-
_collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout asyncDataFetching:YES];
57+
_collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
5858
_collectionView.asyncDataSource = self;
5959
_collectionView.asyncDelegate = self;
6060
_collectionView.layoutInspector = _layoutInspector;

0 commit comments

Comments
 (0)