{"id":3959,"date":"2023-05-04T12:06:22","date_gmt":"2023-05-04T04:06:22","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=3959"},"modified":"2023-05-04T12:06:22","modified_gmt":"2023-05-04T04:06:22","slug":"ios%e5%bc%80%e5%8f%91-wkpreferences%e6%98%af%e4%bb%80%e4%b9%88%e6%84%8f%e6%80%9d%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/3959.html","title":{"rendered":"ios\u5f00\u53d1 wkpreferences\u662f\u4ec0\u4e48\u610f\u601d\u5462\uff1f"},"content":{"rendered":"<p>WKPreferences\u662fWKWebView\u7684\u4e00\u4e2a\u91cd\u8981\u5c5e\u6027\uff0c\u5b83\u5b9a\u4e49\u4e86\u7f51\u9875\u7684\u504f\u597d\u8bbe\u7f6e\uff0c\u5305\u62ec\u4e86\u7f51\u9875\u7684\u7f13\u5b58\u7b56\u7565\u3001\u5b57\u4f53\u5927\u5c0f\u3001\u662f\u5426\u652f\u6301JavaScript\u7b49\u7b49\u3002\u5728iOS\u5f00\u53d1\u4e2d\uff0cWKPreferences\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u7c7b\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u63a7\u5236WKWebView\u7684\u884c\u4e3a\uff0c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>WKPreferences\u7684\u5c5e\u6027<\/p>\n<p>WKPreferences\u6709\u4ee5\u4e0b\u51e0\u4e2a\u5c5e\u6027\uff1a<\/p>\n<p>1. minimumFontSize\uff1a\u8bbe\u7f6e\u7f51\u9875\u7684\u6700\u5c0f\u5b57\u4f53\u5927\u5c0f\u3002<\/p>\n<p>2. javaScriptEnabled\uff1a\u8bbe\u7f6e\u662f\u5426\u652f\u6301JavaScript\u3002<\/p>\n<p>3. javaScriptCanOpenWindowsAutomatically\uff1a\u8bbe\u7f6eJavaScript\u662f\u5426\u53ef\u4ee5\u81ea\u52a8\u6253\u5f00\u65b0\u7a97\u53e3\u3002<\/p>\n<p>4. allowsInlineMediaPlayback\uff1a\u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u5185\u8054\u5a92\u4f53\u64ad\u653e\u3002<\/p>\n<p>5. isFraudulentWebsiteWarningEnabled\uff1a\u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u68c0\u6d4b\u6b3a\u8bc8\u7f51\u7ad9\u3002<\/p>\n<p>6. selectionGranularity\uff1a\u8bbe\u7f6e\u6587\u672c\u9009\u62e9\u7684\u7c92\u5ea6\u3002<\/p>\n<p>7. suppressesIncrementalRendering\uff1a\u8bbe\u7f6e\u662f\u5426\u6291\u5236\u6e10\u8fdb\u5f0f\u6e32\u67d3\u3002<\/p>\n<p>8. tabFocusesLinks\uff1a\u8bbe\u7f6e\u662f\u5426\u4f7f\u7528Tab\u952e\u5207\u6362\u94fe\u63a5\u3002<\/p>\n<p>9. dataDetectorTypes\uff1a\u8bbe\u7f6e\u6570\u636e\u68c0\u6d4b\u7c7b\u578b\u3002<\/p>\n<p>10. urlSchemeHandler\uff1a\u8bbe\u7f6eURL\u65b9\u6848\u5904\u7406\u5668\u3002<\/p>\n<p>WKPreferences\u7684\u4f7f\u7528<\/p>\n<p>\u5728iOS\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7WKPreferences\u6765\u63a7\u5236WKWebView\u7684\u884c\u4e3a\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528WKPreferences\u6765\u8bbe\u7f6e\u7f51\u9875\u7684\u7f13\u5b58\u7b56\u7565\uff1a<\/p>\n<p>&#8220;`swift<\/p>\n<p>let preferences = WKPreferences()<\/p>\n<p>preferences.minimumFontSize = 10<\/p>\n<p>preferences.javaScriptEnabled = true<\/p>\n<p>preferences.javaScriptCanOpenWindowsAutomatically = true<\/p>\n<p>preferences.allowsInlineMediaPlayback = true<\/p>\n<p>preferences.isFraudulentWebsiteWarningEnabled = true<\/p>\n<p>preferences.selectionGranularity = .character<\/p>\n<p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-04\/03\/17\/19666001975.jpg\" \/><\/figure>\n<\/p>\n<p>preferences.suppressesIncrementalRendering = true<\/p>\n<p>preferences.tabFocusesLinks = true<\/p>\n<p>preferences.dataDetectorTypes = [.phoneNumber, .link]<\/p>\n<p>webView.configuration.preferences = preferences<\/p>\n<p>let request = URLReq<a href=\"https:\/\/www.yimenapp.net\/dabao-3989.html\">ios\u4e0a\u4f20ipa<\/a>uest(url: URL(string: &#8220;https:\/\/www.example.com&#8221;)!)<\/p>\n<p>webView.load(request)<\/p>\n<p>&#8220;`<\/p>\n<p><a href=\"https:\/\/www.yimenapp.net\/dabao-1545.html\">android php<\/a>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2aWKPreferences\u5bf9\u8c61\uff0c\u7136\u540e\u8bbe\u7f6e\u4e86\u4e00\u4e9b\u5c5e\u6027\uff0c\u6700\u540e\u5c06\u5176\u8d4b\u503c\u7ed9WKWebView\u7684configuration\u5c5e\u6027\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728WKWebView\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u504f\u597d\u8bbe\u7f6e\u4e86\u3002<\/p>\n<p>\u9664\u4e86\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528WKPreferences\u6765\u63a7\u5236\u7f51\u9875\u7684\u5b57\u4f53\u5927\u5c0f\u3001JavaScript\u652f\u6301\u7b49\u7b49\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6765\u9009\u62e9\u5408\u9002\u7684\u5c5e\u6027\uff0c\u4ee5\u8fbe\u5230\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>WKPreferences\u662fWKWebView\u7684\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u5c5e\u6027\uff0c\u5b83\u5b9a\u4e49\u4e86\u7f51\u9875\u7684\u504f\u597d\u8bbe\u7f6e\uff0c\u5305\u62ec\u4e86\u7f51\u9875\u7684\u7f13\u5b58\u7b56\u7565\u3001\u5b57\u4f53\u5927\u5c0f\u3001\u662f\u5426\u652f\u6301JavaScript\u7b49\u7b49\u3002\u5728iOS\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528WKPreferences\u6765\u63a7\u5236WKWebView\u7684\u884c\u4e3a\uff0c\u4ee5\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WKPreferences\u662fWKWebView\u7684\u4e00\u4e2a\u91cd\u8981\u5c5e\u6027\uff0c\u5b83\u5b9a\u4e49\u4e86\u7f51\u9875\u7684\u504f\u597d\u8bbe\u7f6e\uff0c\u5305\u62ec\u4e86\u7f51\u9875\u7684\u7f13\u5b58\u7b56\u7565\u3001\u5b57\u4f53\u5927\u5c0f\u3001\u662f\u5426\u652f\u6301JavaScript\u7b49\u7b49\u3002\u5728iOS\u5f00\u53d1\u4e2d\uff0cWKPreferences\u662f\u4e00<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[4967,4968,4969,3293,1014],"class_list":["post-3959","post","type-post","status-publish","format-standard","hentry","category-appshangjia","tag-iosapp","tag-ipa","tag-4969","tag-3293","tag-1014"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/3959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=3959"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/3959\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=3959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=3959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=3959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}