From 3ff3bb1681f41ffe49a9bdd8a1d7181014af7204 Mon Sep 17 00:00:00 2001 From: k Date: Wed, 28 Aug 2024 16:02:49 +0900 Subject: [PATCH] https://github.com/pichillilorenzo/flutter_inappwebview/issues/1947 - In iOS version 17.2, when moving the input focus in a WebView, an unknown area appears at the top of the screen. --- .../ios/Classes/InAppWebView/InAppWebView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 25dee18d..889d3a3a 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -728,6 +728,15 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, let newContentOffset = change?[.newKey] as? CGPoint let oldContentOffset = change?[.oldKey] as? CGPoint let startedByUser = scrollView.isDragging || scrollView.isDecelerating + // zpdl9089 : https://github.com/pichillilorenzo/flutter_inappwebview/issues/1947 + if #available(iOS 17.2, *) { + if let y = newContentOffset?.y { + if(!startedByUser && scrollView.contentInset.bottom < 0.0 && y <= scrollView.contentInset.bottom) { + scrollView.contentOffset = oldContentOffset ?? .zero + return + } + } + } if newContentOffset != oldContentOffset { DispatchQueue.main.async { self.onScrollChanged(startedByUser: startedByUser, oldContentOffset: oldContentOffset)