Skip to content

Commit

Permalink
Check that we have the same view after scrolling
Browse files Browse the repository at this point in the history
This can be changed because of cell reuse
  • Loading branch information
dostrander committed Nov 3, 2021
1 parent 252b34e commit 65a7667
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/KIF/Additions/UIAccessibilityElement-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ + (UIView *)viewContainingAccessibilityElement:(UIAccessibilityElement *)element
// Give the scroll view a small amount of time to perform the scroll.
CFTimeInterval delay = animationEnabled ? 0.3 : 0.05;
KIFRunLoopRunInModeRelativeToAnimationSpeed(kCFRunLoopDefaultMode, delay, false);

// Because of cell reuse the first found view could be different after we scroll.
// Find the same element's view to ensure that after we have scrolled we get the same view back.
UIView *checkedView = [UIAccessibilityElement viewContainingAccessibilityElement:element];
// intentionally doing a memory address check vs a isEqual check because
// we want to ensure that the memory address hasn't changed after scroll.
if(view != checkedView) {
view = checkedView;
}
}
}

Expand Down

0 comments on commit 65a7667

Please sign in to comment.