제 질문을 보아 주셔서 감사합니다. 현재 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();
}
원하는 효과는 스크롤 뷰가 새로 정의 된 높이의 끝까지 스크롤 할 수있게하는 것입니다. 그 일에 대해 어떻게 생각하는지에 대한 조언은 크게 감사하겠습니다.