{"id":17004,"date":"2024-03-01T15:31:32","date_gmt":"2024-03-01T07:31:32","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=17004"},"modified":"2024-03-01T15:31:32","modified_gmt":"2024-03-01T07:31:32","slug":"%e7%bd%91%e5%9d%80%e6%89%93%e5%8c%85%e8%8b%b9%e6%9e%9c%e7%89%88%e6%9c%89%e5%93%aa%e4%ba%9b%e6%96%b9%e6%b3%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/17004\/","title":{"rendered":"\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\u6709\u54ea\u4e9b\u65b9\u6cd5\uff1f"},"content":{"rendered":"

\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\uff1a\u5c06\u7f51\u5740\u6253\u5305\u6210\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\u7684\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u4e92\u8054\u7f51\u7684\u4e16\u754c\u91cc\uff0c\u7f51\u7ad9\u662f\u4e2a\u4eba\u548c\u4f01\u4e1a\u8868\u8fbe\u81ea\u6211\u3001\u6269\u5c55\u4e1a\u52a1\u7684\u5e73\u53f0\u3002\u6709\u65f6\uff0c\u7f51\u7ad9\u62e5\u6709\u8005\u60f3\u8981\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u8f6c\u6362\u6210\u4e00\u4e2a\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\uff08\u5982iPhone\u3001iPad\u7b49\uff09\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u6837\u7528\u6237\u53ef\u4ee5\u5728App Store\u4e2d\u4e0b\u8f7d\u5e76\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u5feb\u901f\u8bbf\u95ee\u3002\u8fd9\u5c31\u662f\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\u7684\u610f\u4e49\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u82f9\u679c\u5e94\u7528\u7a0b\u5e8f\u7684\u539f\u7406\u548c\u65b9\u6cd5\u3002<\/p>\n

\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\u7684\u539f\u7406\uff1a<\/p>\n

\u5c06\u7f51\u5740\u6253\u5305\u6210\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\u7684\u5e94\u7528\u7a0b\u5e8f\u662f\u901a\u8fc7\u5c06\u7f51\u7ad9\u5185\u5bb9\u5d4c\u5165\u4e00\u4e2aiOS\u6216iPadOS\u5e94\u7528\u7a0b\u5e8f\u7684\u6846\u67b6\u5185\u5b9e\u73b0\u7684\u3002\u8fd9\u4e2a\u6846\u67b6\u57fa\u4e8eWeb\u6280\u672f\uff0c\u5229\u7528\u82f9\u679c\u8bbe\u5907\u4e0a\u7684WebKit\u5f15\u64ce\u663e\u793a\u7f51\u7ad9\u5185\u5bb9\u3002\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u9700\u8981\u5bf9\u539f\u59cb\u7f51\u7ad9\u8fdb\u884c\u5927\u91cf\u4fee\u6539\u6216\u91cd\u65b0\u8bbe\u8ba1\uff0c\u8282\u7701\u4e86\u65f6\u95f4\u548c\u8d44\u6e90\u3002<\/p>\n

\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

1. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684iOS\u6216iPadOS\u5e94\u7528\u9879\u76ee\u3002<\/p>\n

\u4f7f\u7528Xcode\u5de5\u5177\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684webapp\u5728\u7ebf\u5c01\u88c5<\/a>iOS\u6216iPadOS\u5e94\u7528\u7a0b\u5e8f\u9879\u76ee\u3002\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u5e94\u7528\u7c7b\u578b\u548c\u7f16\u7a0b\u8bed\u8a00\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u4ee5Swift\u7f16\u7a0b\u8bed\u8a00\u4e3a\u4f8b\u3002<\/p>\n

2. \u8bbe\u8ba1\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u3002<\/p>\n

\u5728Xcode\u4e2d\uff0c\u6253\u5f00Main.storyboard\u6587\u4ef6\uff0c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u7528\u6237\u754c\u9762\u3002\u4e3a\u4e86\u5b9e\u73b0\u7f51\u5740\u6253\u5305\uff0c\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u4e00\u4e2aWKWebView\u7ec4\u4ef6\u3002\u8fd9\u4e2a\u7ec4\u4ef6\u662fWebKit\u6846\u67b6\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7d\u548c\u663e\u793a\u7f51\u7ad9\u5185\u5bb9\u3002<\/p>\n

3. \u914d\u7f6eWKWebView\u7ec4\u4ef6\u3002<\/p>\n

\u901a\u8fc7\u62d6\u653e\u7684\u65b9\u5f0f\u5c06WKWebView\u7ec4\u4ef6\u6dfb\u52a0\u5230\u754c\u9762\u4e0a\uff0c\u7136\u540e\u5728Interface Builder\u4e2d\u8bbe\u7f6e\u7ec4\u4ef6\u7684\u5e03\u5c40\u7ea6\u675f\uff0c\u4f7f\u7ec4\u4ef6\u5360\u6ee1\u5c4f\u5e55\u3002\u63a5\u4e0b\u6765\uff0c\u5efa\u7acb\u7ec4\u4ef6\u4e0e\u89c6\u56fe\u63a7\u5236\u5668\u4e4b\u95f4\u7684\u5173\u8054\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2aIBOutlet\u5c5e\u6027\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n

4. \u52a0\u8f7d\u7f51\u7ad9\u5185\u5bb9\u3002<\/p>\n

\u5728\u89c6\u56fe\u63a7\u5236\u5668\u7684\u4ee3\u7801\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199\u4ee3\u7801\u6765\u52a0\u8f7d\u7f51\u7ad9\u5185\u5bb9\u3002\u9996\u5148\uff0c\u5bfc\u5165WebKit\u6846\u67b6\u3002\u7136\u540e\uff0c\u5728\u89c6\u56fe\u63a7\u5236\u5668\u7684viewDidweb\u9879\u76ee\u5c01\u88c5app\u4e00\u95e8<\/a>Load\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n

“`swift<\/p>\n

let webRequest = URLRequest(url: URL(string: “https:\/\/yourwebsite.com”)!)<\/p>\n

webView.load(we<\/p>\n

<\/figure>\n<\/p>\n

bRequest)<\/p>\n

“`<\/p>\n<\/p>\n

\u5c06\u201chttps:\/\/yourwebsite.com\u201d\u66ff\u6362\u4e3a\u4f60\u5e0c\u671b\u5efa\u7acb\u5e94\u7528\u7a0b\u5e8f\u7684\u7f51\u7ad9\u5730\u5740\u3002<\/p>\n

5. \u53d1\u5e03\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u5728\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u5730\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u4e86\u4e00\u4e2a\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u6700\u540e\uff0c\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u5e76\u5c06\u5176\u63d0\u4ea4\u5230App Store\uff0c\u4ee5\u4fbf\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\u4f7f\u5f97\u7f51\u7ad9\u62e5\u6709\u8005\u80fd\u591f\u8f7b\u677e\u5730\u5c06\u7f51\u7ad9\u5185\u5bb9\u6253\u5305\u6210\u82f9\u679c\u8bbe\u5907\u4e0a\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5728App Store\u4e2d\u63d0\u4f9b\u7ed9\u7528\u6237\u3002\u8fd9\u79cd\u65b9\u6cd5\u5229\u7528\u4e86WebKit\u6846\u67b6\uff0c\u65e0\u9700\u5bf9\u539f\u59cb\u7f51\u7ad9\u8fdb\u884c\u5927\u91cf\u4fee\u6539\uff0c\u7b80\u5355\u9ad8\u6548\u3002\u9075\u5faa\u672c\u6587\u63d0\u4f9b\u7684\u8be6\u7ec6\u6559\u7a0b\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u5c06\u4f60\u7684\u7f51\u7ad9\u8f6c\u6362\u6210\u82f9\u679c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7f51\u5740\u6253\u5305\u82f9\u679c\u7248\uff1a\u5c06\u7f51\u5740\u6253\u5305\u6210\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\u7684\u5e94\u7528\u7a0b\u5e8f\u5728\u4e92\u8054\u7f51\u7684\u4e16\u754c\u91cc\uff0c\u7f51\u7ad9\u662f\u4e2a\u4eba\u548c\u4f01\u4e1a\u8868\u8fbe\u81ea\u6211\u3001\u6269\u5c55\u4e1a\u52a1\u7684\u5e73\u53f0\u3002\u6709\u65f6\uff0c\u7f51\u7ad9\u62e5\u6709\u8005\u60f3\u8981\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u8f6c\u6362\u6210\u4e00\u4e2a\u9002\u7528\u4e8e\u82f9\u679c\u8bbe\u5907\uff08\u5982iPhone\u3001iPad\u7b49\uff09<\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[20117,12,14226,247,19],"topic":[],"class_list":["post-17004","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-apph5","tag-12","tag-app","tag-247","tag-19"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17004","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\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=17004"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17004\/revisions"}],"predecessor-version":[{"id":17049,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17004\/revisions\/17049"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=17004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=17004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=17004"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=17004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}