{"id":39775,"date":"2024-04-19T17:24:23","date_gmt":"2024-04-19T09:24:23","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=39775"},"modified":"2024-04-19T17:24:23","modified_gmt":"2024-04-19T09:24:23","slug":"%e6%8a%8a%e7%bd%91%e7%ab%99%e5%81%9a%e6%88%90app%e7%9a%84%e8%bd%af%e4%bb%b6%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appkaifa\/39775.html","title":{"rendered":"\u628a\u7f51\u7ad9\u505a\u6210app\u7684\u8f6f\u4ef6\u6709\u54ea\u4e9b?"},"content":{"rendered":"<p>\u968f\u7740\u79fb\u52a8\u8bbe\u5907\u7684\u666e\u53ca\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5f00\u59cb\u8003\u8651\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u8f6c\u5316\u4e3a\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee5\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u5e76\u589e\u52a0\u7528\u6237\u7559\u5b58\u7387\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5c06\u7f51\u7ad9\u8f6c\u5316\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n<p>\u4e00\u3001\u539f\u7406<\/p>\n<p>\u5c06\u7f51\u7ad9\u8f6c\u5316\u4e3a\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u5c06\u7f51\u7ad9\u7684HTML\u3001CSS\u3001JavaScript\u7b49\u8d44\u6e90\u6253\u5305\u5230\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u901a\u8fc7WebView\u52a0\u8f7d\u5c55\u793a\u3002WebView\u662f\u4e00\u79cd\u5d4c\u5165\u5f0f\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5d4c\u5165\u7f51\u9875\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8bbf\u95ee\u7f51\u7ad9\u3002<\/p>\n<p>\u4e8c\u3001\u8be6\u7ec6\u6b65\u9aa4<\/p>\n<p>1. \u51c6\u5907\u5de5\u4f5c<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u4f60\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a\u7f51\u7ad9\uff0c\u5e76\u4e14\u7f51\u7ad9\u80fd\u591f\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u6b63\u5e38\u5c55\u793a\u3002\u540c\u65f6\uff0c\u4f60\u9700\u8981\u4e0b\u8f7d\u5e76\u5b89\u88c5Android Studio\u6216Xcode\u7b49\u5f00\u53d1\u5de5\u5177\u3002<\/p>\n<p>2. \u521b\u5efa\u9879\u76ee<\/p>\n<p>\u6253\u5f00Android Studio\u6216Xcode\u7b49\u5f00\u53d1\u5de5\u5177\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002\u5728\u521b\u5efa\u9879\u76ee\u7684\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u6a21\u677f\uff0c\u5e76\u586b\u5199\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\uff0c\u5982\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3001\u5305\u540d\u3001\u7248\u672c\u7b49\u3002<\/p>\n<p>3. \u6dfb\u52a0WebView<\/p>\n<p>\u5728\u9879\u76ee\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u7528\u4e8e\u52a0\u8f7d\u7f51\u7ad9\u3002\u5728Android Studio\u4e2d\uff0c\u53ef\u4ee5\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d<a href=\"https:\/\/www.yimenapp.cn\/fengzhuang-3812.html\">\u4e2a\u4ebaapp\u5236\u4f5c\u514d\u8d39\u5e73\u53f0<\/a>\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>&#8220;`<\/p>\n<\/p>\n<p>    android:id=&#8221;@+id\/webView&#8221;<\/p>\n<p>    android:lay<a href=\"https:\/\/www.yimenapp.cn\/fengzhuang-2765.html\">android\u6709\u54ea\u4e9b\u5f00\u53d1\u6846\u67b6<\/a>out_width=&#8221;match_parent&#8221;<\/p>\n<p>    android:layout_height=&#8221;match_parent&#8221; \/&gt;<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728Xcode\u4e2d\uff0c\u53ef\u4ee5\u5728Storyboard\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>![WebView in Xcode](https:\/\/i.imgur.com\/1yvB0jK.png)<\/p>\n<p>4. \u52a0\u8f7d\u7f51\u7ad9<\/p>\n<p>\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\uff0c\u9700\u8981\u901a\u8fc7WebView\u52a0\u8f7d\u7f51\u7ad9\u3002\u5728Android Studio\u4e2d\uff0c\u53ef\u4ee5\u5728Activity\u7684onCreate\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>WebView webView = findViewById(R.id.webView);<\/p>\n<p>webView.loadUrl(&#8220;https:\/\/www.example.com&#8221;);<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728Xcode\u4e2d\uff0c\u53ef\u4ee5\u5728ViewController\u7684viewDidLoad\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>let url = URL(string: &#8220;https:\/\/www.example.com&#8221;)!<\/p>\n<p>let request = URLRequest(url: url)<\/p>\n<p>webView.load(request)<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u914d\u7f6eWebView<\/p>\n<p>\u4e3a\u4e86\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u9700\u8981\u5bf9WebView\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u3002\u5728Android Studio\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u542f\u7528JavaScript\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>WebView webView = findViewById(R.id.webView);<\/p>\n<p>webView.getSettings().setJavaScriptEnabled(true);<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728Xcode\u4e2d\uff0c\u53ef\u4ee5\u5728Storyboard\u4e2d\u52fe\u9009\u201cEnable JavaScript\u201d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>![Enable JavaScript in Xcode](https:\/\/i.imgur.com\/0ZwPmDg.png)<\/p>\n<p>6. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u9700\u8981\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u5e76\u53d1\u5e03\u5230\u5e94\u7528\u5546\u5e97\u3002\u5728Android Studio\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Build\u83dc\u5355\u4e2d\u7684\u201cGenerate Signed Bundle<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/24\/10\/35700001097.jpg\" \/><\/figure>\n<\/p>\n<p>\/APK\u201d\u9009\u9879\uff0c\u751f\u6210APK\u6587\u4ef6\u3002\u5728Xcode\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Product\u83dc\u5355\u4e2d\u7684\u201cArchive\u201d\u9009\u9879\uff0c\u751f\u6210IPA\u6587\u4ef6\u3002<\/p>\n<p>7. \u53d1\u5e03\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5c06\u6253\u5305\u597d\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0a\u4f20\u5230Google Play\u6216App Store\u7b49\u5e94\u7528\u5546\u5e97\uff0c\u5e76\u8fdb\u884c\u5ba1\u6838\u3002\u5ba1\u6838\u901a\u8fc7\u540e\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u5728\u5e94\u7528\u5546\u5e97\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u5c06\u7f51\u7ad9\u8f6c\u5316\u4e3a\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u5e76\u589e\u52a0\u7528\u6237\u7559\u5b58\u7387\u3002\u901a\u8fc7WebView\u52a0\u8f7d\u7f51\u7ad9\uff0c\u5e76\u5bf9WebView\u8fdb\u884c\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u548c\u7f51\u7ad9\u4e4b\u95f4\u7684\u8f6c\u5316\u66f4\u52a0\u81ea\u7136\u548c\u6d41\u7545\u3002\u540c\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u5e94\u7528\u7a0b\u5e8f\u7684\u6253\u5305\u548c\u53d1\u5e03\u6d41\u7a0b\uff0c\u4ee5\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u548c\u88ab\u7528\u6237\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740\u79fb\u52a8\u8bbe\u5907\u7684\u666e\u53ca\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5f00\u59cb\u8003\u8651\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u8f6c\u5316\u4e3a\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee5\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u5e76\u589e\u52a0\u7528\u6237\u7559\u5b58\u7387\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5c06\u7f51\u7ad9\u8f6c\u5316\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002\u4e00\u3001\u539f\u7406\u5c06\u7f51\u7ad9\u8f6c\u5316\u4e3a\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u5c06<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[36491,1775,36492,842,83],"class_list":["post-39775","post","type-post","status-publish","format-standard","hentry","category-appkaifa","tag-app","tag-1775","tag-app-","tag-842","tag-83"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/39775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=39775"}],"version-history":[{"count":1,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/39775\/revisions"}],"predecessor-version":[{"id":39858,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/39775\/revisions\/39858"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=39775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=39775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=39775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}