<\/figure>\n<\/p>\n super.onCreate(savedInstanceState);<\/p>\n
setContentView(R.layout.activity_webview);<\/p>\n
WebView webView = findViewById(R.id.webview);<\/p>\n
WebSettings webSettings = webView.getSettings();<\/p>\n
webSettings.setJavaScriptEnabled(true);<\/p>\n
webView.loadUrl(“https:\/\/example.com”);<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
(4) \u6d4b\u8bd5APP\uff0c\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u6700\u540e\u751f\u6210\u5b89\u88c5\u5305\u5e76\u53d1\u5e03\u5230\u5e94\u7528\u5546\u5e97\u3002<\/p>\n
2. iOS\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n
(1) \u4f7f\u7528Xcode\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u539f\u751fAPP\u9879\u76ee\u3002<\/p>\n
(2) \u5728\u9879\u76ee\u4e2d\uff0c\u6253\u5f00Main.storyboard\uff0c\u4eceObject Library\u4e2d\u62d6\u62fd\u4e00\u4e2aWKWebView\u7ec4\u4ef6\u5230View Controller\u4e0a\uff0c\u5e76\u8bbe\u7f6eAutolayout\u7ea6\u675f\uff0c\u4f7f\u5176\u5360\u636e\u6574\u4e2a\u5c4f\u5e55\u3002<\/p>\n
(3) \u4f7f\u7528Assistant\u7f16\u8f91\u5668\uff0c\u6dfb\u52a0IBOutlet\u5c5e\u6027\uff0c\u4e3aWKWebView\u521b\u5efa\u5f15\u7528\uff1a<\/p>\n
“`swift<\/p>\n
import UIKit<\/p>\n
import WebKit<\/p>\n
class ViewController: UIViewController {<\/p>\n
@IBOutlet weak var webView: WKWebView!<\/p>\n
}<\/p>\n
“`<\/p>\n
(4) \u4fee\u6539ViewController.swift\u6587\u4ef6\uff0c\u4fee\u6539\u5176\u7ee7\u627f\u7c7b\u4e3aWKNavigationDelegate\uff0c\u5e76\u5728viewDidLoad()\u65b9\u6cd5\u4e2d\u8bbe\u7f6e\u5e76\u52a0\u8f7dURL\uff1a<\/p>\n
“`swift<\/p>\n
import UIKit<\/p>\n
import WebKit<\/p>\n
class ViewController: UIViewController, WKNavigationDelegate {<\/p>\n
@IBOutlet weak var webView: WKWebView!<\/p>\n
override func viewDidLoad() {<\/p>\n
super.viewDidLoad()<\/p>\n
webView.navigationDelegate = self<\/p>\n
let url = URL(string: “https:\/\/example.com”)!<\/p>\n
webView.load(URLRequest(url: url))<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
(5) \u6d4b\u8bd5APP\uff0c\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u6700\u540e\u751f\u6210\u5b89\u88c5\u5305\u5e76\u53d1\u5e03\u5230\u5e94\u7528\u5546\u5e97\u3002<\/p>\n
\u5c06\u7f51\u9875\u751f\u6210APP\u7684\u8fc7\u7a0b\u5c31\u5b8c\u6210\u4e86\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8eWebView\u5185\u7f6e\u7684\u6d4f\u89c8\u5668\u7248\u672c\u4e0d\u540c\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u9488\u5bf9\u4e00\u4e9b\u53ef\u80fd\u51fa\u73b0\u7684\u517c\u5bb9\u6027\u95ee\u9898\u8fdb\u884c\u8c03\u6574\u3002\u5e0c\u671b\u4ee5\u4e0a\u4fe1\u606f\u80fd\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5c06\u4e00\u4e2a\u7f51\u9875\u751f\u6210APP\uff08\u5e94\u7528\u7a0b\u5e8f\uff09\u7684\u8fc7\u7a0b\u4e3b\u8981\u662f\u7531WebView\u6280\u672f\u5b9e\u73b0\u7684\u3002WebView\u662f\u4e00\u4e2a\u5185\u5d4c\u5728\u539f\u751fAPP\u4e2d\u7684\u6d4f\u89c8\u5668\u89c6\u7a97\uff0c\u652f\u6301\u6d4f\u89c8\u7f51\u9875\u3001\u6267\u884cJS\u811a\u672c\u7b49\u529f\u80fd\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u76f4\u63a5\u5c06\u7f51\u9875\u5185\u5bb9\u5d4c\u5165APP\u4e2d<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[2325,10448,736,149,6140],"topic":[],"class_list":["post-8840","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-2325","tag-app","tag-736","tag-149"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=8840"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8840\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=8840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=8840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=8840"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=8840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}