diff --git a/ios/Classes/InAppWebView.swift b/ios/Classes/InAppWebView.swift index 7418b63d9..5a5a2eac4 100755 --- a/ios/Classes/InAppWebView.swift +++ b/ios/Classes/InAppWebView.swift @@ -856,6 +856,10 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi if (options?.clearCache)! { clearCache() } + + if #available(iOS 13.0, *) { + scrollView.automaticallyAdjustsScrollIndicatorInsets = (options?.automaticallyAdjustsScrollIndicatorInsets)! + } } @available(iOS 10.0, *) @@ -1239,7 +1243,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi if error != nil { let userInfo = (error! as NSError).userInfo - self.onConsoleMessage(message: userInfo["WKJavaScriptExceptionMessage"] as! String, messageLevel: 3) + self.onConsoleMessage(message: userInfo["WKJavaScriptExceptionMessage"] as? String ?? "", messageLevel: 3) } if value == nil { diff --git a/ios/Classes/InAppWebViewOptions.swift b/ios/Classes/InAppWebViewOptions.swift index 67f129d60..202d260cf 100755 --- a/ios/Classes/InAppWebViewOptions.swift +++ b/ios/Classes/InAppWebViewOptions.swift @@ -49,6 +49,7 @@ public class InAppWebViewOptions: Options { var dataDetectorTypes: [String] = ["NONE"] // WKDataDetectorTypeNone var preferredContentMode = 0 var sharedCookiesEnabled = false + var automaticallyAdjustsScrollIndicatorInsets = true override init(){ super.init() diff --git a/lib/src/webview_options.dart b/lib/src/webview_options.dart index ef6c72cc4..a418b2f8e 100644 --- a/lib/src/webview_options.dart +++ b/lib/src/webview_options.dart @@ -606,6 +606,12 @@ class IosInAppWebViewOptions ///**NOTE**: available on iOS 11.0+. bool sharedCookiesEnabled; + ///Set `false` if scrollView of WKWebView should not automatically adjust scroll indicator insets. + ///The default value is `true`. + /// + ///**NOTE**: available on iOS 13.0+. + bool automaticallyAdjustsScrollIndicatorInsets; + IosInAppWebViewOptions( {this.disallowOverScroll = false, this.enableViewportScale = false, @@ -619,7 +625,8 @@ class IosInAppWebViewOptions this.isFraudulentWebsiteWarningEnabled = true, this.selectionGranularity = IosInAppWebViewSelectionGranularity.DYNAMIC, this.dataDetectorTypes = const [IosInAppWebViewDataDetectorTypes.NONE], - this.sharedCookiesEnabled = false}); + this.sharedCookiesEnabled = false, + this.automaticallyAdjustsScrollIndicatorInsets = true}); @override Map toMap() { @@ -643,7 +650,9 @@ class IosInAppWebViewOptions "isFraudulentWebsiteWarningEnabled": isFraudulentWebsiteWarningEnabled, "selectionGranularity": selectionGranularity.toValue(), "dataDetectorTypes": dataDetectorTypesList, - "sharedCookiesEnabled": sharedCookiesEnabled + "sharedCookiesEnabled": sharedCookiesEnabled, + "automaticallyAdjustsScrollIndicatorInsets": + automaticallyAdjustsScrollIndicatorInsets }; }