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 513 of file FlutterPlatformViews.mm.

Method Documentation

◆ accessibilityContainer

- (id) accessibilityContainer

Provided by category FlutterTouchInterceptingView(Tests).

◆ blockGesture

- (void) blockGesture

Definition at line 510 of file FlutterPlatformViews.mm.

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

◆ embeddedView

- (UIView*) embeddedView

◆ initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:

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

Definition at line 510 of file FlutterPlatformViews.mm.

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

◆ releaseGesture

- (void) releaseGesture

Definition at line 510 of file FlutterPlatformViews.mm.

557  {
558  self.delayingRecognizer.state = UIGestureRecognizerStateFailed;
559 }

Property Documentation

◆ flutterAccessibilityContainer

- (id) flutterAccessibilityContainer
readwritenonatomicretain

Definition at line 150 of file FlutterPlatformViews_Internal.h.


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