Flutter iOS Embedder
FlutterTouchInterceptingView Class Reference

#import <FlutterPlatformViews_Internal.h>

Inheritance diagram for FlutterTouchInterceptingView:

Instance Methods

(instancetype) - initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:
 
(void) - releaseGesture
 
(void) - blockGesture
 
(UIView *) - embeddedView
 
(id) - accessibilityContainer
 

Properties

id flutterAccessibilityContainer
 

Detailed Description

Definition at line 518 of file FlutterPlatformViews.mm.

Method Documentation

◆ accessibilityContainer

- (id) accessibilityContainer

Provided by category FlutterTouchInterceptingView(Tests).

◆ blockGesture

- (void) blockGesture

Definition at line 515 of file FlutterPlatformViews.mm.

614  {
615  switch (_blockingPolicy) {
617  // We block all other gesture recognizers immediately in this policy.
618  self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
619 
620  // On iOS 18.2, WKWebView's internal recognizer likely caches the old state of its blocking
621  // recognizers (i.e. delaying recognizer), resulting in non-tappable links. See
622  // https://github.com/flutter/flutter/issues/158961. Removing and adding back the delaying
623  // recognizer solves the problem, possibly because UIKit notifies all the recognizers related
624  // to (blocking or blocked by) this recognizer. It is not possible to inject this workaround
625  // from the web view plugin level. Right now we only observe this issue for
626  // FlutterPlatformViewGestureRecognizersBlockingPolicyEager, but we should try it if a similar
627  // issue arises for the other policy.
628  if (@available(iOS 26.0, *)) {
629  // This performs a nested DFS, with the outer one searching for any web view, and the inner
630  // one searching for a TouchEventsGestureRecognizer inside the web view. Once found, disable
631  // and immediately reenable it to reset its state.
632  // TODO(hellohuanlin): remove this flag after it is battle tested.
633  NSNumber* isWorkaroundDisabled =
634  [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTDisableWebViewGestureReset"];
635  if (!isWorkaroundDisabled.boolValue) {
636  [self searchAndFixWebView:self.embeddedView];
637  }
638  } else if (@available(iOS 18.2, *)) {
639  // This workaround is designed for WKWebView only. The 1P web view plugin provides a
640  // WKWebView itself as the platform view. However, some 3P plugins provide wrappers of
641  // WKWebView instead. So we perform DFS to search the view hierarchy (with a depth limit).
642  // Passing a limit of 0 means only searching for platform view itself; Pass 1 to include its
643  // children as well, and so on. We should be conservative and start with a small number. The
644  // AdMob banner has a WKWebView at depth 7.
645  if ([self containsWebView:self.embeddedView remainingSubviewDepth:1]) {
646  [self removeGestureRecognizer:self.delayingRecognizer];
647  [self addGestureRecognizer:self.delayingRecognizer];
648  }
649  }
650 
651  break;
653  if (self.delayingRecognizer.touchedEndedWithoutBlocking) {
654  // If touchesEnded of the `DelayingGesureRecognizer` has been already invoked,
655  // we want to set the state of the `DelayingGesureRecognizer` to
656  // `UIGestureRecognizerStateEnded` as soon as possible.
657  self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
658  } else {
659  // If touchesEnded of the `DelayingGesureRecognizer` has not been invoked,
660  // We will set a flag to notify the `DelayingGesureRecognizer` to set the state to
661  // `UIGestureRecognizerStateEnded` when touchesEnded is called.
662  self.delayingRecognizer.shouldEndInNextTouchesEnded = YES;
663  }
664  break;
665  default:
666  break;
667  }
668 }
@ FlutterPlatformViewGestureRecognizersBlockingPolicyEager
@ FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded

◆ embeddedView

- (UIView*) embeddedView

◆ initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:

- (instancetype) initWithEmbeddedView: (UIView*)  embeddedView
platformViewsController: (FlutterPlatformViewsController*)  platformViewsController
gestureRecognizersBlockingPolicy: (FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy 

Definition at line 515 of file FlutterPlatformViews.mm.

519  :(UIView*)embeddedView
520  platformViewsController:(FlutterPlatformViewsController*)platformViewsController
521  gestureRecognizersBlockingPolicy:
523  self = [super initWithFrame:embeddedView.frame];
524  if (self) {
525  self.multipleTouchEnabled = YES;
526  _embeddedView = embeddedView;
527  embeddedView.autoresizingMask =
528  (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
529 
530  [self addSubview:embeddedView];
531 
532  ForwardingGestureRecognizer* forwardingRecognizer =
533  [[ForwardingGestureRecognizer alloc] initWithTarget:self
534  platformViewsController:platformViewsController];
535 
536  _delayingRecognizer =
537  [[FlutterDelayingGestureRecognizer alloc] initWithTarget:self
538  action:nil
539  forwardingRecognizer:forwardingRecognizer];
540  _blockingPolicy = blockingPolicy;
541 
542  [self addGestureRecognizer:_delayingRecognizer];
543  [self addGestureRecognizer:forwardingRecognizer];
544  }
545  return self;
546 }
FlutterPlatformViewGestureRecognizersBlockingPolicy

◆ releaseGesture

- (void) releaseGesture

Definition at line 515 of file FlutterPlatformViews.mm.

562  {
563  self.delayingRecognizer.state = UIGestureRecognizerStateFailed;
564 }

Property Documentation

◆ flutterAccessibilityContainer

- (id) flutterAccessibilityContainer
readwritenonatomicretain

Definition at line 154 of file FlutterPlatformViews_Internal.h.


The documentation for this class was generated from the following files: