diff --git a/Sources/KIF/Additions/UIView-KIFAdditions.m b/Sources/KIF/Additions/UIView-KIFAdditions.m index bde10305..3c2b30d3 100644 --- a/Sources/KIF/Additions/UIView-KIFAdditions.m +++ b/Sources/KIF/Additions/UIView-KIFAdditions.m @@ -380,6 +380,7 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi [collectionView scrollRectToVisible:visibleRect animated:NO]; [collectionView layoutIfNeeded]; UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; + NSAssert(cell, @"UICollectionViewCell returned from 'cellForItemAtIndexPath' is unexpectedly nil!"); UIAccessibilityElement *element = [cell accessibilityElementMatchingBlock:matchBlock notHidden:NO disableScroll:NO]; // Skip this cell if it isn't the one we're looking for @@ -395,6 +396,7 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi } [collectionView setContentOffset:initialPosition.origin]; + [collectionView layoutIfNeeded]; CFRunLoopRunInMode(UIApplicationCurrentRunMode, CELL_SCROLL_DELAY_STABILIZATION, false); } }