From 527a62b5621a0e53e4bdcaaeb163454e33bab20a Mon Sep 17 00:00:00 2001 From: Michal Srutek Date: Wed, 20 Dec 2023 12:01:40 +0100 Subject: [PATCH] Fix iPad crash due to missing sourceView --- .../ios/Classes/InAppBrowser/InAppBrowserManager.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift index f1cad31d..481e2a64 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift @@ -114,7 +114,15 @@ public class InAppBrowserManager: ChannelDelegate { assertionFailure("Failure init the visibleViewController!") return } - + + if let popover = navController.popoverPresentationController { + let sourceView = visibleViewController.view ?? UIView() + + popover.sourceRect = CGRect(x: sourceView.bounds.midX, y: sourceView.bounds.midY, width: 0, height: 0) + popover.permittedArrowDirections = [] + popover.sourceView = sourceView + } + visibleViewController.present(navController, animated: animated) }