{"id":10034,"date":"2023-11-27T13:11:15","date_gmt":"2023-11-27T05:11:15","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=10034"},"modified":"2023-11-27T13:11:15","modified_gmt":"2023-11-27T05:11:15","slug":"%e7%bd%91%e9%a1%b5%e5%b0%81%e8%a3%85%e6%88%90%e5%85%8d%e7%ad%beios%e4%bc%aaapp%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/11\/27\/%e7%bd%91%e9%a1%b5%e5%b0%81%e8%a3%85%e6%88%90%e5%85%8d%e7%ad%beios%e4%bc%aaapp%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0\/","title":{"rendered":"\u7f51\u9875\u5c01\u88c5\u6210\u514d\u7b7eios\u4f2aapp\u5982\u4f55\u5b9e\u73b0?"},"content":{"rendered":"

\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\uff0c\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u7ef4\u62a4\u6210\u672c\u8f83\u9ad8\u3002\u4f46\u662f\uff0c\u8fd8\u6709\u4e00\u79cd\u6280\u672f\u53ef\u4ee5\u5c06\u5df2\u6709\u7684\u7f51\u9875\u5c01\u88c5\u4e3a\u4e00\u4e2a\u514d\u7b7eiOS\u4f2aAPP\uff0c\u8fd9\u79cd\u65b9\u6cd5\u91c7\u7528\u7f51\u9875\u5e94\u7528\u6280\u672f\uff08Web App\uff0c\u4e5f\u79f0\u4e3a\u6df7\u5408\u5f0f\u5e94\u7528\uff09\u6765\u5b9e\u73b0\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u5411\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e2a\u8fc7\u7a0b\u548c\u539f\u7406\u3002<\/p>\n

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

Web App\u662f\u4e00\u79cd\u5c06\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u76f4\u63a5\u5c01\u88c5\u5230\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6280\u672f\u3002\u7b80\u800c\u8a00\u4e4b\uff0c\u5b83\u5c31\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u89c6\u56fe\uff08Web View\uff09\u5d4c\u5165\u5230\u4e00\u4e2aiOS\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u8ba9\u7528\u6237\u62e5\u6709\u66f4\u597d\u7684\u79fb\u52a8\u4f53\u9a8c\uff0c\u5e76\u907f\u514d\u4e86\u56e0\u4e3a\u53d1\u5e03\u5728App Store\u800c\u9700\u8981\u7b7e\u540d\u8bc1\u4e66\u3002\u5bf9\u4e8e\u5df2\u7ecf\u62e5\u6709\u7f51\u7ad9\u8d44\u6e90\uff08HTML\u3001CSS\u548cJavaScript\uff09\u7684\u5f00\u53d1\u8005\u6765\u8bf4\uff0cWeb App\u662f\u4e00\u79cd\u8282\u7701\u65f6\u95f4\u548c\u6210\u672c\u7684\u65b9\u6cd5\u3002<\/p>\n

\u4e8c\u3001\u8be6\u7ec6\u6b65\u9aa4<\/p>\n

1. \u51c6\u5907\u5de5\u4f5c<\/p>\n

\u786e\u4fdd\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7f51\u7ad9\uff08\u81ea\u9002\u5e94\u5c4f\u5e55\u5bbd\u5ea6\u7684\u8bbe\u8ba1\uff09\uff0c\u6216\u8005\u4e13\u4e3a\u79fb\u52a8\u8bbe\u5907\u5b9a\u5236\u7684\u7f51\u7ad9\u3002\u8fd9\u80fd\u591f\u7ed9\u4e88\u7528\u6237\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u6d41\u7545\u7684\u4f53\u9a8c\u3002<\/p>\n

2. \u5efa\u7acb\u4e00\u4e2a\u65b0\u7684Xcode\u9879\u76ee<\/p>\n

\u4e0b\u8f7d\u5e76\u5b89\u88c5Xcode\uff08\u82f9\u679c\u5b98\u65b9\u7684\u5f00\u53d1\u5de5\u5177\uff09\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684iOS\u9879\u76ee\u3002\u5728\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u9009\u62e9”Single View App”\u6a21\u677f\u3002\u7ed9\u9879\u76ee\u8d77\u4e2a\u540d\u5b57\uff0c\u4f8b\u5982”MyWebApp”\u3002<\/p>\n

3. \u6dfb\u52a0\u7f51\u9875\u89c6\u56fe\uff08WebView\uff09\u548c\u7ea6\u675f<\/p>\n

\u5728Xcode\u4e2d\uff0c\u6253\u5f00”Main.storyboard”\u6587\u4ef6\u3002\u641c\u7d22”WebView”\uff0c\u4eceObject Library\u628a\u5b83\u62d6\u653e\u5230\u53ef\u89c6\u5316\u7f16\u8f91\u533a\u3002\u63a5\u7740\u4e3aWebView\u6dfb\u52a0\u56db\u4e2a\u7ea6ios\u798f\u5229\u8f6f\u4ef6\u514d\u8d39\u81ea\u7b7e\u6559\u7a0b<\/a>\u675f\uff1a\u4e0e\u7236\u89c6\u56fe\u4e0a\u3001\u4e0b\u3001\u5de6\u3001\u53f3\u8fb9\u8ddd\u90fd\u4e3a0\u3002\u8fd9\u6837WebView\u5c31\u4f1a\u81ea\u52a8\u9002\u914d\u5c4f\u5e55\u5c3a\u5bf8\u3002<\/p>\n

4. \u8bbe\u7f6e\u52a0\u8f7d\u7f51\u9875\u7684\u4ee3\u7801<\/p>\n

\u9996\u5148\uff0c\u5728”MyWebApp”\u9879\u76ee\u4e2d\u542f\u7528WebKit\u6846\u67b6\u3002\u63a5\u7740\uff0c\u6253\u5f00”ViewController.swift”\u6587\u4ef6\u3002\u5728”import UIKit”\u4e0b\u4e00\u884c\uff0c\u8f93\u5165”import WebKit”\u3002\u7136\u540e\u5c06”viewDidLoad()”\u51fd\u6570\u4fee\u6539\u4e3a\u5982\u4e0b\u5f62\u5f0f\uff1a<\/p>\n

“`<\/p>\n

override func viewDidLoad() {<\/p>\n

super.viewDidLoad()<\/p>\n<\/p>\n

\/\/ \u521d\u59cb\u5316\u7f51\u9875\u89c6\u56fe<\/p>\n

let webView = self.view as! WKWebView<\/p>\n

\/\/ \u8bbe\u7f6e\u7f51\u5740<\/p>\n

let webUrl = URL(str<\/p>\n

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

ing: “http:\/\/your-web-app-url”)!<\/p>\n

\/\/ \u52a0\u8f7d\u5b8c\u6574\u7684\u9875\u9762<\/p>\n

webView.load(URLRequest(url: webUrl))<\/p>\n

}<\/p>\n

“`<\/p>\n

\u8bb0\u5f97\u5c06”your-web-app-url”\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u7f51\u7ad9\u5730\u5740\u3002<\/p>\n

webclip\u5982\u4f55\u4f7f\u7528<\/a>5. \u7f16\u8bd1\u548c\u6d4b\u8bd5<\/p>\n

\u5728\u6a21\u62df\u5668\u6216\u771f\u673a\u8bbe\u5907\u4e0a\u8fd0\u884c”MyWebApp”\u9879\u76ee\u3002\u4e00\u65e6\u8fd0\u884c\u6210\u529f\uff0c\u60a8\u5c31\u53ef\u4ee5\u5728iOS\u8bbe\u5907\u4e0a\u901a\u8fc7\u8fd9\u4e2a\u514d\u7b7e\u4f2aApp\u6d4f\u89c8\u60a8\u7684\u7f51\u7ad9\u4e86\u3002<\/p>\n

\u6700\u540e\uff0c\u8bf7\u6ce8\u610f\uff0c\u5c06\u7f51\u9875\u5c01\u88c5\u4e3a\u514d\u7b7eiOS\u4f2aAPP\u5e76\u975e\u82f9\u679c\u5b98\u65b9\u63a8\u8350\u7684\u65b9\u6cd5\uff0c\u5c24\u5176\u662f\u5982\u679c\u60a8\u60f3\u628a\u5e94\u7528\u7a0b\u5e8f\u4e0a\u67b6\u5230App Store\u3002\u4f46\u5bf9\u4e8e\u4e2a\u4eba\u5f00\u53d1\u8005\u548c\u6559\u80b2\u76ee\u7684\uff0cWeb App\u662f\u4e00\u4e2a\u7b80\u5355\u6613\u884c\u7684\u9009\u62e9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\uff0c\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u7ef4\u62a4\u6210\u672c\u8f83\u9ad8\u3002\u4f46\u662f\uff0c\u8fd8\u6709\u4e00\u79cd\u6280\u672f\u53ef\u4ee5\u5c06\u5df2\u6709\u7684\u7f51\u9875\u5c01\u88c5\u4e3a\u4e00\u4e2a\u514d\u7b7eiOS\u4f2aAPP\uff0c\u8fd9\u79cd\u65b9\u6cd5\u91c7\u7528\u7f51\u9875\u5e94\u7528\u6280\u672f\uff08Web App\uff0c\u4e5f\u79f0\u4e3a\u6df7\u5408\u5f0f\u5e94\u7528\uff09\u6765\u5b9e\u73b0\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u5411\u60a8\u8be6<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[11021,116,414,3884,812],"topic":[],"class_list":["post-10034","post","type-post","status-publish","format-standard","hentry","category-iosmainqian","tag-webclip","tag-116","tag-414","tag-3884","tag-812"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/10034","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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=10034"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/10034\/revisions"}],"predecessor-version":[{"id":10209,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/10034\/revisions\/10209"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=10034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=10034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=10034"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=10034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}