\u82f9\u679ciOS\u6c38\u4e45\u514d\u7b7e<\/a>NavigationDelegate {<\/p>\n var webView: WKWebView!<\/p>\n
override func loadView() {<\/p>\n
webView = WKWebView()<\/p>\n
webView.navigationDelegate = self<\/p>\n
view = webView<\/p>\n
}<\/p>\n
override func viewDidLoad() {<\/p>\n
super.viewDidLoad()<\/p>\n
let url = URL(string: “https:\/\/www.example.com”)!<\/p>\n
webView.load(URLRequest(url: url))<\/p>\n
webView.allowsBackForwardNavigationGestures = true<\/p>\n
}<\/p>\n
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {<\/p>\n
title = webView.title<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
3. \u8bbe\u7f6e WebView \u7684\u4ee3\u7406\uff0c\u5b9e\u73b0\u7f51\u9875\u52a0\u8f7d\u5b8c\u6210\u540e\u7684\u56de\u8c03\u3002\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u8bbe\u7f6e ViewController \u4e3a WebView \u7684\u4ee3\u7406\uff0c\u5e76\u5b9e\u73b0\u4e86 `webView(_:didFinish:)` \u65b9\u6cd5\uff0c\u5f53\u7f51\u9875\u52a0\u8f7d\u5b8c\u6210\u540e\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\u3002\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u5c06\u7f51\u9875\u7684\u6807\u9898\u8bbe\u7f6e\u4e3a ViewController \u7684\u6807\u9898\u3002<\/p>\n
4. \u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u7684 Info.plist \u6587\u4ef6\uff0c\u6dfb\u52a0 App Transport Security Settings \u5b57\u6bb5\uff0c\u5141\u8bb8\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee HTTP \u7f51\u7ad9\u3002\u5728\u8be5\u5b57\u6bb5\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n
“`<\/p>\n
NSAppTransportSecurity<\/p>\n
\n
NSAllowsArbitraryLoads<\/p>\n<\/p>\n
“`<\/p>\n
5. \u7f16\u8bd1\u5e76\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u770b\u5230 WebView \u4e2d\u5df2\u7ecf\u52a0\u8f7d\u4e86\u6307\u5b9a\u7684\u7f51\u7ad9\u3002\u5982\u679c\u9700\u8981\u66f4\u6539\u7f51\u7ad9\u7684\u5730\u5740\uff0c\u53ea\u9700\u8981\u4fee\u6539\u4ee3\u7801\u4e2d\u7684 URL \u5373\u53ef\u3002<\/p>\n
6. \u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210 ipa \u6587\u4ef6\uff0c\u5e76\u4e0a\u4f20\u5230 App Store \u4e0a\u67b6\u3002<\/p>\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7f51\u7ad9\u5c01\u88c5 iOS \u4ec5\u9002\u7528\u4e8e\u7b80\u5355\u7684\u7f51\u7ad9\uff0c\u5bf9\u4e8e\u590d\u6742\u7684\u7f51\u7ad9\u53ef\u80fd\u4f1a\u5b58\u5728\u517c\u5bb9\u6027\u95ee\u9898\u3002\u6b64\u5916\uff0c\u7f51\u7ad9\u5c01\u88c5 iOS \u4e5f\u65e0\u6cd5\u5b9e\u73b0\u4e00\u4e9b\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u5177\u5907\u7684\u529f\u80fd\uff0c\u5982\u63a8\u9001\u901a\u77e5\u3001\u79bb\u7ebf\u7f13\u5b58\u7b49\u3002\u56e0\u6b64\uff0c\u5728\u8fdb\u884c\u7f51\u7ad9\u5c01\u88c5 iOS \u4e4b\u524d\u9700\u8981\u8fdb\u884c\u5145\u5206\u7684\u8bc4\u4f30\u548c\u6d4b\u8bd5\uff0c\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u548c\u517c\u5bb9\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u7f51\u7ad9\u5c01\u88c5 iOS \u662f\u6307\u5c06\u4e00\u4e2a\u7f51\u7ad9\u5c01\u88c5\u6210\u4e00\u4e2a iOS \u5e94\u7528\u7a0b\u5e8f\uff0c\u8ba9\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 iOS \u8bbe\u5907\u8f7b\u677e\u5730\u8bbf\u95ee\u8be5\u7f51\u7ad9\u3002\u5c01\u88c5\u540e\u7684\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728 App Store \u4e0a\u67b6\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u4ece App Store \u4e0b\u8f7d<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12434,1623,38,116,194],"topic":[],"class_list":["post-6957","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-android-web-","tag-app-","tag-38","tag-116","tag-194"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=6957"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6957\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=6957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=6957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=6957"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=6957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}