{"id":952,"date":"2023-07-27T13:04:54","date_gmt":"2023-07-27T05:04:54","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=952"},"modified":"2023-07-27T13:04:54","modified_gmt":"2023-07-27T05:04:54","slug":"web%e6%89%93%e5%8c%85%e8%8b%b9%e6%9e%9capp%e6%98%af%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/952\/","title":{"rendered":"web\u6253\u5305\u82f9\u679capp\u662f\u600e\u4e48\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"

\u4e00\u952e\u6253\u5305\u82f9\u679capp<\/a><\/p>\n

Web\u6253\u5305\u82f9\u679cApp\u662f\u4e00\u79cd\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u539f\u751fiOS\u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u901a\u8fc7\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u5305\u88c5\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u6765\u5b9e\u73b0\u5728iOS\u8bbe\u5907\u4e0a\u4ee5\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u7684\u5f62\u5f0f\u8fd0\u884c\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7App Store\u5206\u53d1\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecdWeb\u6253\u5305\u82f9\u679cApp\u7684\u539f\u7406\u548c\u6b65\u9aa4\u3002<\/p>\n

\u4e00\u3001\u539f\u7406\uff1a<\/p>\n

Web\u6253\u5305\u82f9\u679cApp\u7684\u539f\u7406\u662f\u901a\u8fc7\u4f7f\u7528\u4e00\u4e2aWeb\u5bb9\u5668\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u52a0\u8f7d\u5230iOS\u8bbe\u5907\u4e0a\uff0c\u5e76\u5728\u5bb9\u5668\u4e2d\u63d0\u4f9b\u4e00\u4e2aWebView\u63a7\u4ef6\u6765\u663e\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5bb9\u3002WebView\u63a7\u4ef6\u57fa\u4e8eWebKit\u5f15\u64ce\uff0c\u5141\u8bb8\u5c06Web\u5185\u5bb9\u6e32\u67d3\u4e3a\u539f\u751fiOS\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u4e8c\u3001\u6b65\u9aa4\uff1a<\/p>\n

1. \u786e\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u6807\u8bbe\u5907\u548c\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff1a\u5728\u5f00\u59cbWeb\u6253\u5305\u82f9\u679cApp\u4e4b\u524d\uff0c\u9700\u8981\u786e\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u6807\u8bbe\u5907\u548c\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff0c\u4ee5\u4fbf\u4f7f\u7528\u6b63\u786e\u7684\u5f00\u53d1\u5de5\u5177\u548c\u5e73\u53f0\u3002<\/p>\n

2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Xcode\u9879\u76ee\uff1a\u6253\u5f00Xcode\uff0c\u9009\u62e9\u201cCreate a new Xcode project\u201d\uff0c\u9009\u62e9\u201cSingle Vie<\/p>\n

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

w App\u201d\uff0c\u586b\u5199\u9879\u76ee\u7684\u540d\u79f0\u3001\u7ec4\u7ec7\u6807\u8bc6\u7b26\u7b49\u4fe1\u606f\u3002<\/p>\n

3. \u914d\u7f6e\u9879\u76ee\u8bbe\u7f6e\uff1a\u5728Xcode\u9879\u76ee\u4e2d\uff0c\u9009\u62e9\u201cSigning & Capabilities\u201d\uff0c\u786e\u4fdd\u6709\u4e00\u4e2a\u6709\u6548\u7684\u5f00\u53d1\u8005\u5e10\u6237\u3002<\/p>\n

4. \u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff1a\u5728\u9879\u76ee\u7684\u4e3b\u9875\u9762\u4e0a\u62d6\u52a8\u5e76\u653e\u7f6e\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u8bbe\u7f6e\u5176\u5927\u5c0f\u548c\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528Interface Builder\u6216\u8005\u4ee3\u7801\u65b9\u5f0f\u6765\u5b8c\u6210\u3002<\/p>\n

5. \u52a0\u8f7dWeb\u5e94\u7528\u7a0b\u5e8f\uff1a\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5728WebView\u63a7\u4ef6\u4e2d\u52a0\u8f7dWeb\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

let url = URL(string: “https:\/\/www.example.com”)<\/p>\n

let request = URLRequest(url: url!)<\/p>\n

webView.load(request)<\/p>\n

“`<\/p>\n

6. \u6dfb\u52a0\u5176\u4ed6\u529f\u80fd\uff1a\u6839\u636e\u9700\u8981\uff0c\u53ef\u4ee5\u6dfb\u52a0\u5176\u4ed6\u529f\u80fd\uff0c\u5982\u5bfc\u822a\u680f\u3001\u82f9\u679c\u8bc1\u4e66\u53ef\u4ee5\u7ed9\u591a\u4e2aapp\u6253\u5305\u5417<\/a>\u5de5\u5177\u680f\u3001\u63a8\u9001\u901a\u77e5\u7b49\u3002<\/p>\n

7. \u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\u548c\u542f\u52a8\u753b\u9762\uff1a\u5728Xcode\u9879\u76ee\u4e2d\uff0c\u9009\u62e9\u201cAssets.xcassets\u201d\uff0c\u6dfb\u52a0\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\u548c\u542f\u52a8\u753b\u9762\u3002<\/p>\n

8. \u6d4b\u8bd5\u548c\u8c03\u8bd5\uff1a\u5728Xcode\u4e2d\u4f7f\u7528\u6a21\u62df\u5668\u6216\u8005\u771f\u673a\u6765\u6d4b\u8bd5\u548c\u8c03\u8bd5\u5e94\u7528\u7a0b\u5e8f\u3002\u53ef\u4ee5\u901a\u8fc7Xcode\u63d0\u4f9b\u7684\u8c03\u8bd5\u529f\u80fd\u548c\u5f00\u53d1\u8005\u5de5\u5177\u6765\u67e5\u627e\u548c\u4fee\u590d\u9519\u8bef\u3002<\/p>\n

9. \u6253\u5305\u548c\u5206\u53d1\uff1a\u5728\u5b8c\u6210\u6d4b\u8bd5\u548c\u8c03\u8bd5\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Xcode\u8fdb\u884c\u6253\u5305\uff0c\u5e76\u901a\u8fc7App Store\u6216\u8005\u5176\u4ed6\u5206\u53d1\u6e20\u9053\u5c06\u5e94\u7528\u7a0b\u5e8f\u53d1\u5e03\u5230\u7528\u6237\u3002<\/p>\n

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

Web\u6253\u5305\u82f9\u679cApp\u662f\u4e00\u79cd\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8f6c\u5316\u4e3a\u539f\u751fiOS\u5e94\u7528\u7a0b\u5e8f\u7684\u6280\u672f\u3002\u5b83\u4f7f\u7528Web\u5bb9\u5668\u548cWebView\u63a7\u4ef6\u6765\u6e32\u67d3\u5e76\u663e\u793aWeb\u5185\u5bb9\uff0c\u5e76\u63d0\u4f9b\u539f\u751fiOS\u5e94\u7528\u7a0b\u5e8f\u7684\u5916\u89c2\u548c\u529f\u80fd\u3002\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u82f9\u679cApp\uff0c\u5e76\u901a\u8fc7App Store\u5206\u53d1\u7ed9\u7528\u6237\u4f7f\u7528\u3002\u8fd9\u79cd\u65b9\u6cd5\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u5730\u521b\u5efa\u8de8\u5e73\u53f0\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u878d\u5408Web\u6280\u672f\u548c\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u7684\u4f18\u70b9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Web\u6253\u5305\u82f9\u679cApp\u662f\u4e00\u79cd\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u539f\u751fiOS\u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u901a\u8fc7\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u5305\u88c5\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u6765\u5b9e\u73b0\u5728iOS\u8bbe\u5907\u4e0a\u4ee5\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u7684\u5f62\u5f0f\u8fd0\u884c\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7App Store\u5206\u53d1<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[2200,12,989,19,2207],"topic":[],"class_list":["post-952","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-app","tag-12","tag-989","tag-19"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/952","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=952"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/952\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=952"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}