How To Put A WKWebView Inside A UIScrollView In iOS (UIKit / Swift)
When you embed a WKWebView
inside a UIScrollView
in iOS, the size of the WKWebView
may not change as expected because of conflicting constraints. By default, the WKWebView
may have its own intrinsic content size based on the content being displayed, while the UIScrollView
may try to adjust its content size based on its constraints.
Listening for the WKWebView to complete loading its content, and then using JavaScript to calculate the height of the WKWebView and adjust the size of the WKWebView and the content size of the UIScrollView is a common approach for resolving these types of issues.
Comments
Post a Comment