私の質問を見ていただきありがとうございます。現在、いくつかの入力フィールドと、UIScrollViewに埋め込まれたWKWebViewがあります。イベントが発生する前に、すべてのサブビューが問題なくスクロールビューに収まります。 WKNavigationDelegateにあるDidFinishNavigationデリゲートで取得されたdocument.body.scrollHeightに基づいて、WKの高さを動的に設定しています。 WKの高さが設定されると、WKは表示可能なコンテンツを超えて拡張されます。ここでは、スクロールビューにサイズ変更を強制しようとしているコードを示します。UIScrollViewのレンダリング後にスクロールしないWKWebViewのコンテンツ
[Export("webView:didFinishNavigation:")] public async void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
{
//get the webView's initial height
var initialHeight = webView.Frame.Height;
//get height of HTML's document.body.scrollHeight
var contentHeight = await GetContentHeight();
//create new frame for webview
CGRect newWebViewFrame = new CGRect(webView.Frame.X, webView.Frame.Y, webView.Frame.Width, contentHeight);
//set webview's frame
webView.Frame = newWebViewFrame;
//get the difference of webView's initial height and webView's current height
var differenceInHeight = contentHeight - initialHeight;
//create new cgrect and set the height to svMain's height + the difference in height of the HTML document
CGRect newScrollViewFrame = new CGRect(0, 0, svMainScroller.Frame.Width, svMainScroller.Frame.Height + differenceInHeight);
//set MainScroller's frame
svMainScroller.Frame = newScrollViewFrame;
//force scrolling
svMainScroller.ScrollEnabled = true;
//scrolling should be handled in the main scroller
webView.ScrollView.ScrollEnabled = false;
svMainScroller.SizeToFit();
}
所望の効果は、スクロールビューが新たに定義された高さの最後までスクロールすることができることです。どのように私はそれを行うことについて行くすべてのヒントは非常に高く評価されるだろう。