{"id":23272,"date":"2024-03-18T11:58:25","date_gmt":"2024-03-18T03:58:25","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=23272"},"modified":"2024-03-18T11:58:25","modified_gmt":"2024-03-18T03:58:25","slug":"html-%e6%96%87%e4%bb%b6-%e6%89%93%e5%8c%85%e4%b8%ba-%e5%ae%89%e5%8d%93%e5%92%8cios%e5%ba%94%e7%94%a8%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2024\/appkfa\/23272\/","title":{"rendered":"html \u6587\u4ef6 \u6253\u5305\u4e3a \u5b89\u5353\u548cios\u5e94\u7528\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>\u5c06 HTML \u6587\u4ef6\u6253\u5305\u4e3a\u5b89\u5353\u548c iOS \u5e94\u7528\u7684\u8fc7\u7a0b\uff0c\u5176\u5b9e\u5c31\u662f\u5c06 HTML \u6587\u4ef6\u8f6c\u5316\u4e3a\u539f\u751f\u5e94\u7528\u3002\u8fd9\u79cd\u65b9\u6cd5\u6bd4\u8d77\u81ea\u5df1\u7f16\u5199\u539f\u751f\u5e94\u7528\uff0c\u53ef\u4ee5\u7701\u53bb\u5f88\u591a\u5f00\u53d1\u65f6\u95f4\u548c\u6210\u672c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u5c06 HTML \u6587\u4ef6\u6253\u5305\u4e3a\u5b89\u5353\u548c iOS \u5e94\u7528\u3002<\/p>\n<p>\u4e00\u3001\u5b89\u5353\u5e94\u7528<\/p>\n<p>\u5b89\u5353\u5e94\u7528\u7684\u6253\u5305\u9700\u8981\u7528\u5230 Android Studio\uff0c\u5b83\u662f\u4e00\u4e2a\u5b98\u65b9\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u53ef\u4ee5\u4e3a\u5b89\u5353\u8bbe\u5907\u521b\u5efa\u539f\u751f\u5e94\u7528\u3002<\/p>\n<p>1. \u4e0b\u8f7d Android Studio<\/p>\n<p>\u9996\u5148\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5 Android Studio\uff0c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9700\u8981\u9009\u62e9\u5b89\u88c5 Android SDK \u548c Android Virtual Device\uff08AVD\uff09\u3002<\/p>\n<p>2. \u521b\u5efa\u65b0\u9879\u76ee<\/p>\n<p>\u6253\u5f00 Android Studio\uff0c\u9009\u62e9 Create New Project\uff0c\u7136\u540e\u586b\u5199\u9879\u76ee\u540d\u79f0\u548c\u5e94\u7528\u5305\u540d\u3002\u5728\u9009\u62e9 Minimum SDK \u7248\u672c\u65f6\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u4e0d\u540c\u7684\u7248\u672c\u3002<\/p>\n<p>3. \u6dfb\u52a0 WebView \u7ec4\u4ef6<\/p>\n<p>\u5728\u9879\u76ee\u4e2d\u6dfb\u52a0 WebView \u7ec4\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5e94\u7528\u4e2d\u52a0\u8f7d HTML \u6587\u4ef6\u3002\u5728 layout \u6587\u4ef6\u5939\u4e2d\u6253\u5f00 activity_main.xml \u6587\u4ef6\uff0c\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u6dfb\u52a0\u5230\u6587\u4ef6\u4e2d\uff1a<\/p>\n<p>&#8220;`<\/p>\n<\/p>\n<p>    android:id=&#8221;@+id\/webview&#8221;<\/p>\n<p>    android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>    android:layout_height=&#8221;match_parent&#8221; \/&gt;<\/p>\n<p>&#8220;`<\/p>\n<p>4. \u52a0\u8f7d HTML \u6587\u4ef6<\/p>\n<p>\u5728 MainActivity.java \u6587<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/31\/16\/32692039485.jpg\" \/><\/figure>\n<\/p>\n<p>\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u6765\u52a0\u8f7d HTML \u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>WebView webView = (WebView) findViewById(R.id.webview);<\/p>\n<p>webVi<a href=\"https:\/\/www.yimenapp.net\/dabao-592.html\">\u4e91\u6253\u5305x5\u5185\u6838\u4e0d\u751f\u6548<\/a>ew.loadUrl(&#8220;file:\/\/\/android_asset\/index.html&#8221;);<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0cfile:\/\/\/android_asset\/ \u8868\u793a HTML \u6587\u4ef6\u5728\u5e94\u7528\u7684 assets \u6587\u4ef6\u5939\u4e2d\uff0cindex.html \u662f HTML \u6587\u4ef6\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<p>5. \u6253\u5305\u5e94\u7528<\/p>\n<p>\u5728 Android Studio \u4e2d\uff0c\u9009\u62e9 Build &gt; Generate Signed APK\uff0c\u7136\u540e\u586b\u5199 Keystore \u4fe1\u606f\u3002\u6700\u540e\uff0c\u9009\u62e9 Build Variant \u548c Build Type\uff0c\u5373\u53ef\u751f\u6210 APK \u6587\u4ef6\u3002<\/p>\n<p>\u4e8c\u3001iOS \u5e94\u7528<\/p>\n<p>iOS \u5e94\u7528\u7684\u6253\u5305\u9700\u8981\u7528\u5230 Xcode\uff0c\u5b83\u662f\u82f9\u679c\u516c\u53f8\u5b98\u65b9\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u4e3a iOS \u8bbe\u5907\u521b\u5efa\u539f\u751f\u5e94\u7528\u3002<\/p>\n<p>1. \u4e0b\u8f7d Xcode<\/p>\n<p>\u9996\u5148\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5 Xcode\uff0c\u5b83\u53ea\u80fd\u5728 Mac \u4e0a\u8fd0\u884c\u3002<\/p>\n<p>2. \u521b\u5efa\u65b0\u9879\u76ee<\/p>\n<p>\u6253\u5f00 Xcode\uff0c\u9009\u62e9 Create a new Xcode project\uff0c\u7136\u540e\u9009\u62e9 Single View Application \u6a21\u677f\u3002\u586b\u5199\u9879\u76ee\u540d\u79f0\u548c\u7ec4\u7ec7\u540d\u79f0\uff0c\u5e76\u9009\u62e9\u8bed\u8a00\u4e3a Swift \u6216 Objective-C\u3002<\/p>\n<p>3. \u6dfb\u52a0 WebView \u7ec4\u4ef6<\/p>\n<p>\u5728 Main.storyboard \u6587\u4ef6\u4e2d\uff0c\u5c06\u4e00\u4e2a WebView \u7ec4\u4ef6\u62d6\u653e\u5230 View Controller \u4e2d\u3002<\/p>\n<p>4. \u52a0\u8f7d HTML \u6587\u4ef6<\/p>\n<p>\u5728 ViewController.swift \u6216 ViewController.m \u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u6765\u52a0\u8f7d HTML \u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>let url = Bundle.main.url(forResource: &#8220;index&#8221;, withExtension: &#8220;html&#8221;, subdirectory: &#8220;www&#8221;)!<\/p>\n<p>let request = URLRequest(url: url)<\/p>\n<p>webView.load(re<a href=\"https:\/\/www.yimenapp.net\/dabao-1823.html\">\u5b89\u5353\u7f51\u9875\u751f\u6210apk<\/a>quest)<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0cindex.html \u662f HTML \u6587\u4ef6\u7684\u6587\u4ef6\u540d\uff0cwww \u662f\u5b58\u653e HTML \u6587\u4ef6\u7684\u6587\u4ef6\u5939\u540d\u3002<\/p>\n<p>5. \u6253\u5305\u5e94\u7528<\/p>\n<p>\u5728 Xcode \u4e2d\uff0c\u9009\u62e9 Product &gt; Archive\uff0c\u7136\u540e\u9009\u62e9\u8981\u6253\u5305\u7684\u8bbe\u5907\u548c\u7248\u672c\u3002\u4e4b\u540e\uff0c\u53ef\u4ee5\u9009\u62e9 Export \u6216 Distribute App \u6765\u5bfc\u51fa IPA \u6587\u4ef6\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c06 HTML \u6587\u4ef6\u6253\u5305\u4e3a\u5b89\u5353\u548c iOS \u5e94\u7528\u7684\u8be6\u7ec6\u4ecb\u7ecd\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5c06 HTML \u6587\u4ef6\u8f6c\u5316\u4e3a\u539f\u751f\u5e94\u7528\uff0c\u65b9\u4fbf\u7528\u6237\u4f7f\u7528\u3002\u540c\u65f6\uff0c\u4e5f\u53ef\u4ee5\u8282\u7701\u5f00\u53d1\u65f6\u95f4\u548c\u6210\u672c\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06 HTML \u6587\u4ef6\u6253\u5305\u4e3a\u5b89\u5353\u548c iOS \u5e94\u7528\u7684\u8fc7\u7a0b\uff0c\u5176\u5b9e\u5c31\u662f\u5c06 HTML \u6587\u4ef6\u8f6c\u5316\u4e3a\u539f\u751f\u5e94\u7528\u3002\u8fd9\u79cd\u65b9\u6cd5\u6bd4\u8d77\u81ea\u5df1\u7f16\u5199\u539f\u751f\u5e94\u7528\uff0c\u53ef\u4ee5\u7701\u53bb\u5f88\u591a\u5f00\u53d1\u65f6\u95f4\u548c\u6210\u672c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u5c06 HTML \u6587\u4ef6\u6253\u5305\u4e3a<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[16056,3735,4374,81,442],"topic":[],"class_list":["post-23272","post","type-post","status-publish","format-standard","hentry","category-appkfa","tag-iapp","tag-3735","tag-4374","tag-81","tag-442"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=23272"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23272\/revisions"}],"predecessor-version":[{"id":23299,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23272\/revisions\/23299"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=23272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=23272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=23272"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=23272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}