File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -765,7 +765,35 @@ - (BOOL)isProbablyTappable
765
765
// Is this view currently on screen?
766
766
- (BOOL )isTappable ;
767
767
{
768
- return [self isTappableInRect: self .bounds];
768
+ return ([self hasTapGestureRecognizerAndIsControlEnabled ] ||
769
+ [self isTappableInRect: self .bounds]);
770
+ }
771
+
772
+ - (BOOL )hasTapGestureRecognizerAndIsControlEnabled
773
+ {
774
+ __block BOOL hasTapGestureRecognizer = NO ;
775
+
776
+ [self .gestureRecognizers enumerateObjectsUsingBlock: ^(id obj,
777
+ NSUInteger idx,
778
+ BOOL *stop) {
779
+ if ([obj isKindOfClass: [UITapGestureRecognizer class ]]) {
780
+ hasTapGestureRecognizer = YES ;
781
+
782
+ if (stop != NULL ) {
783
+ *stop = YES ;
784
+ }
785
+ }
786
+ }];
787
+
788
+ // In iOS 15 UIButton's still have tap gesture recognizers when disabled.
789
+ // This prevents a control that is disabled, but still has the system gesture
790
+ // recognizers to say it's tappable.
791
+ if ([self isKindOfClass: [UIControl class ]]) {
792
+ UIControl *control = (UIControl *)self;
793
+ return hasTapGestureRecognizer && control.isEnabled ;
794
+ }
795
+
796
+ return hasTapGestureRecognizer;
769
797
}
770
798
771
799
- (BOOL )isTappableInRect : (CGRect )rect ;
You can’t perform that action at this time.
0 commit comments