ios - WKWebView equivalent for UIWebView's scalesPageToFit -
I change your iOS app to change I found this solution on the Web but it does not work: You can also try WKUserScript. Here's my working configuration: You can add additional configurations to your WKWebViewConfiguration. UIWebView to
WKWebView I'm updating. Although I do not understand how to get the same behavior with
WKWebView . I used
scalesPageToFit with
UIWebView to ensure the web pag was displayed with the same size as the screen size (so that full screen is displayed without scrolling ).
- (zero) webview: (wk webview *) webview was communicated: (wk navigation * Navigation {nssting * javascript = @ "met meta = document.createElement ('meta'); meta.setAttribute ('name', 'viewport'); meta.setAttribute ('content', 'width = device-width, Initial-scale = 1.0, max-scale = 1.0, user scalable = no '); document. GetElementsByTagName (' head ') [0] .appendChild (meta); "; [Evaluate webview javascript: javascript closing handler: zero]; }
NSString * jScript = @ "var meta = document.createElement ('meta'); meta.setAttribute ('name' , 'Viewport'); meta.setAttribute ('content', 'widthth = device-width'); document.getElementsByTagName ('head') [0] .appendChild (meta); "; WKUserScript * wkUScript = [[WKUserScript alloc] initWithSource: JScript Injection Time: WKUserScriptInjectionTimeAtDocumentEndforMainFrameOnly: Yes]; WKUserContentController * wkUController = [[WKUserContentController alloc] init]; [WkUController addUserScript: wkUScript]; WKWebViewConfiguration * wkWebConfig = [[WKWebViewConfiguration alloc] init]; WkWebConfig.userContentController = wkUController; WkWebV = [[WKWebView alloc] initWithFrame: self.view.frame configuration: wkWebConfig];
Comments
Post a Comment