diff --git a/Sources/KIF/Additions/UIView-KIFAdditions.m b/Sources/KIF/Additions/UIView-KIFAdditions.m index a2776d72..a9e9e297 100644 --- a/Sources/KIF/Additions/UIView-KIFAdditions.m +++ b/Sources/KIF/Additions/UIView-KIFAdditions.m @@ -765,7 +765,35 @@ - (BOOL)isProbablyTappable // Is this view currently on screen? - (BOOL)isTappable; { - return [self isTappableInRect:self.bounds]; + return ([self hasTapGestureRecognizerAndIsControlEnabled] || + [self isTappableInRect:self.bounds]); +} + +- (BOOL)hasTapGestureRecognizerAndIsControlEnabled +{ + __block BOOL hasTapGestureRecognizer = NO; + + [self.gestureRecognizers enumerateObjectsUsingBlock:^(id obj, + NSUInteger idx, + BOOL *stop) { + if ([obj isKindOfClass:[UITapGestureRecognizer class]]) { + hasTapGestureRecognizer = YES; + + if (stop != NULL) { + *stop = YES; + } + } + }]; + + // In iOS 15 UIButton's still have tap gesture recognizers when disabled. + // This prevents a control that is disabled, but still has the system gesture + // recognizers to say it's tappable. + if ([self isKindOfClass:[UIControl class]]) { + UIControl *control = (UIControl *)self; + return hasTapGestureRecognizer && control.isEnabled; + } + + return hasTapGestureRecognizer; } - (BOOL)isTappableInRect:(CGRect)rect;