Skip to content

Commit 6345bf6

Browse files
authored
Merge pull request #1312 from kif-framework/markj/collection_view_scroll_fix
Fix for collection view scrolling not working in some tests
2 parents 4218eae + 97c176f commit 6345bf6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/KIF/Additions/UIView-KIFAdditions.m

+5
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
380380
[collectionView scrollRectToVisible:visibleRect animated:NO];
381381
[collectionView layoutIfNeeded];
382382
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
383+
if (cell == nil) {
384+
[collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
385+
[collectionView layoutIfNeeded];
386+
cell = [collectionView cellForItemAtIndexPath:indexPath];
387+
}
383388
NSAssert(cell, @"UICollectionViewCell returned from 'cellForItemAtIndexPath' is unexpectedly nil!");
384389
UIAccessibilityElement *element = [cell accessibilityElementMatchingBlock:matchBlock notHidden:NO disableScroll:NO];
385390

0 commit comments

Comments
 (0)