{"id":20860,"date":"2024-01-05T18:32:12","date_gmt":"2024-01-05T10:32:12","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=20860"},"modified":"2024-01-05T18:32:12","modified_gmt":"2024-01-05T10:32:12","slug":"%e6%90%ad%e5%bb%ba%e7%bd%91%e7%ab%99%e7%94%9f%e6%88%90app%e6%8e%a8%e8%8d%90%e4%bd%bf%e7%94%a8%e4%b8%80%e9%97%a8app%e5%bc%80%e5%8f%91%e5%b9%b3%e5%8f%b0","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaapp\/20860\/","title":{"rendered":"\u642d\u5efa\u7f51\u7ad9\u751f\u6210app\u63a8\u8350\u4f7f\u7528\u4e00\u95e8APP\u5f00\u53d1\u5e73\u53f0"},"content":{"rendered":"<p>\u5728\u4e92\u8054\u7f51\u9886\u57df\uff0c\u5c06\u4e00\u4e2a\u7f51\u7ad9\u8f6c\u6362\u6210APP\u5e94\u7528\u662f\u4e00\u79cd\u5f88\u666e\u904d\u7684\u9700\u6c42\u3002\u901a\u5e38\uff0c\u7528\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6838\u5fc3\u6280\u672f\u662f\u79f0\u4e3aWebview\u7684\u7ec4\u4ef6\u3002Webview\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u5bb9\u5668\u6765\u52a0\u8f7d\u7f51\u9875\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u6210\u4e00\u4e2a\u5b9e\u9645\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u6559\u7a0b\uff0c\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u4f60\u7684\u7f51\u7ad9\u8f6c\u6362\u6210\u4e00\u4e2aAPP\u3002<\/p>\n<p>1. \u4e86\u89e3Webview\u6280\u672f<\/p>\n<p>Webview\u662f\u539f\u751f\u5e94\u7528\u4e2d\u7684\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u7528\u4e8e\u52a0\u8f7d\u548c\u663e\u793a\u7f51<a href=\"http:\/\/www.yimenyun.cn\/zaixian-shengcheng-app-119.html\">app\u5728\u7ebf\u751f\u6210\u8f6f\u4ef6<\/a>\u9875\u3002\u5b83\u5728Android\u548ciOS\u7cfb\u7edf\u4e2d\u8868\u73b0\u4e3a\uff1aAndroid\u7684WebView\u7c7b\uff0c\u4ee5\u53caiOS\u7684UIWebView\u6216WKWebView\u7c7b\u3002Webview\u4e3aWeb\u5185\u5bb9\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6c99\u76d2\u73af\u5883\uff0c\u5c06\u5176\u5d4c\u5165\u5728\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002<\/p>\n<p>2. \u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5<\/p>\n<p>\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u5c06\u7f51\u7ad9\u8f6c\u6362\u6210APP\u3002<\/p>\n<p>&#8211; \u539f\u751f\u5e94\u7528\u5f00\u53d1\uff1a\u4f60\u53ef\u4ee5\u4f7f\u7528\u539f\u751f\u5e94\u7528\u5f00\u53d1\u5de5\u5177\uff08\u5982Android Studio\uff0cXcode\uff09\u5206\u522b\u4e3aAndroid\u548ciOS\u521b\u5efa\u4e00\u4e2a\u539f\u751f\u5e94\u7528\uff0c\u7136\u540e\u5728\u5e94\u7528\u4e2d\u4f7f\u7528Webview\u52a0\u8f7d\u7f51\u7ad9\u3002<\/p>\n<p>&#8211; \u6df7\u5408\u5e94\u7528\u5f00\u53d1\uff1a\u4f7f\u7528\u6df7\u5408\u5e94\u7528\u5f00\u53d1\u6846\u67b6\uff08\u5982Cordova\uff0cReact Nati<a href=\"http:\/\/www.yimenyun.cn\/app-shengcheng-gongju-502.html\">asp\u7f51\u7ad9\u751f\u6210app<\/a>ve\uff0cFlutter\uff09\u5f00\u53d1\u4e00\u6b3e\u80fd\u5728\u591a\u4e2a\u5e73\u53f0\uff08\u5982Android\uff0ciOS\uff09\u8fd0\u884c\u7684\u5e94\u7528\uff0c\u5e76\u5728\u5176\u5185\u90e8\u4f7f\u7528Webview\u7ec4\u4ef6\u52a0\u8f7d\u7f51\u7ad9\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u7840\u6559\u7a0b\uff0c\u5e2e\u52a9\u4f60\u642d\u5efa\u4f60\u7684\u7f51\u7ad9APP\u3002<\/p>\n<p>**\u539f\u751f\u5e94\u7528\u5f00\u53d1**<\/p>\n<p>&#8211; \u5bf9\u4e8eAndroid\uff1a<\/p>\n<p>  1. \u5b89\u88c5\u5e76\u542f\u52a8Android Studio\u3002<\/p>\n<p>  2. \u70b9\u51fb&#8221;Start a new Android Studio Project&#8221;\u3002<\/p>\n<p>  3. \u5728&#8221;Create New Project&#8221;\u5bf9\u8bdd\u6846\u4e2d\u9009\u62e9&#8221;Empty Activity&#8221;\uff0c\u7136\u540e\u70b9\u51fb&#8221;Next&#8221;\u3002<\/p>\n<p>  4. \u586b\u5199\u76f8\u5e94\u7684&#8221;Application Name&#8221;\uff0c&#8221;Package Name&#8221;\uff0c&#8221;Save Location&#8221;\u7b49\u4fe1\u606f\uff0c\u7136\u540e\u70b9\u51fb&#8221;Finish&#8221;\u521b\u5efa\u9879\u76ee\u3002<\/p>\n<p>  5. \u6253\u5f00&#8221;activity_main.xml&#8221;\u5e03\u5c40\u6587\u4ef6\uff0c\u5e76\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230XML\u5e03\u5c40\u4e2d\uff1a<\/p>\n<p>&#8220;`xml<\/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>  6. \u5728&#8221;MainActivity.java&#8221;\u7c7b\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\uff1a<\/p>\n<p>&#8220;`java<\/p>\n<p>import android.webkit.WebSettings;<\/p>\n<p>import android.webkit.WebView;<\/p>\n<p>import android.webkit.WebViewClient;<\/p>\n<p>public class MainActivity extends AppCompatActivity {<\/p>\n<p>    private WebView webView;<\/p>\n<p>    @Override<\/p>\n<p>    protected void onCreate(Bundle savedInstanceState) {<\/p>\n<p>        super.onCreate(savedInstanceState);<\/p>\n<p>        setContentView(R.layout.activity_main);<\/p>\n<p>        webView = findViewById(R.id.webview);<\/p>\n<p>        WebSettings webSettings = webView.getSettings();<\/p>\n<p>        webSettings.setJavaScriptEnabled(true);<\/p>\n<p>        webView.setWebViewClient(new WebViewClient());<\/p>\n<p>        webView.loadUrl(&#8220;https:\/\/\u4f60\u7684\u7f51\u7ad9URL&#8221;);<\/p>\n<p>    }<\/p>\n<p>    @Override<\/p>\n<p>    public void onBackPressed() {<\/p>\n<p>        if (webView.canGoBack()) {<\/p>\n<p>            webView.goBack();<\/p>\n<p>        } else {<\/p>\n<p>            super.onBackPressed();<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>  7. \u786e\u4fdd\u5728AndroidManifest.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0INTERNET\u6743\u9650\uff1a<\/p>\n<p>&#8220;`xml<\/p>\n<p>\n<p>    &#8230;<\/p>\n<\/p>\n<p>    &#8230;<\/p>\n<\/p>\n<p>&#8220;`<\/p>\n<p>  8. \u70b9\u51fb\u8fd0\u884c\u6216\u751f\u6210APK\u5b89\u88c5\u5305\u3002<\/p>\n<p>&#8211; \u5bf9\u4e8eiOS\uff1a<\/p>\n<p>  1. \u5b89\u88c5\u5e76\u542f\u52a8Xcode\u3002<\/p>\n<p>  2. \u70b9\u51fb&#8221;Create a new Xcode project&#8221;\u3002<\/p>\n<p>  3. \u9009\u62e9&#8221;Single View App&#8221;\uff0c\u7136\u540e\u70b9\u51fb&#8221;Next&#8221;\u3002<\/p>\n<p>  4. \u586b\u5199\u76f8\u5e94\u7684&#8221;Product Name&#8221;\uff0c&#8221;Organization Identifier&#8221;\u7b49\u4fe1\u606f\uff0c\u7136\u540e\u70b9\u51fb&#8221;Finish&#8221;\u521b\u5efa\u9879\u76ee\u3002<\/p>\n<p>  5. \u628aWKWebView\u4ece\u5e93\u4e2d\u62d6\u66f3\u5230Storyboard\u4e2d\uff0c\u5e76\u8ba9\u5176\u5145\u6ee1\u6574\u4e2a\u753b\u5e03\u3002\u6dfb\u52a0\u7ea6\u675f\u4ee5\u81ea\u9002\u5e94\u4e0d\u540c\u5c4f\u5e55\u5927\u5c0f\u3002<\/p>\n<p>  6. \u5728ViewController.swift\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`swift<\/p>\n<p>import WebKit<\/p>\n<p>class ViewController: UIViewController, WKNavigationDelegate {<\/p>\n<p>    var webView: WKWebView!<\/p>\n<p>    override func viewDidLoad() {<\/p>\n<p>        super.viewDidLoad()<\/p>\n<p>        webView = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())<\/p>\n<p>        webView.translatesAutoresizingMaskIntoConstraints = false<\/p>\n<p>        webView.navigationDelegate = self<\/p>\n<p>        view.addSubview(webView)<\/p>\n<p>        NSLayoutConstraint.activate([<\/p>\n<p>            webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),<\/p>\n<p>            webView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),<\/p>\n<p>            webView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.lef<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-01\/06\/16\/15876303298.jpg\" \/><\/figure>\n<\/p>\n<p>tAnchor),<\/p>\n<p>            webView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor)<\/p>\n<p>        ])<\/p>\n<p>        let url = URL(string: &#8220;https:\/\/\u4f60\u7684\u7f51\u7ad9URL&#8221;)!<\/p>\n<p>        webView.load(URLRequest(url: url))<\/p>\n<p>    }<\/p>\n<p>    override func didReceiveMemoryWarning() {<\/p>\n<p>        super.didReceiveMemoryWarning()<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>  7. \u70b9\u51fb\u8fd0\u884c\u6216\u751f\u6210IPA\u5b89\u88c5\u5305\u3002<\/p>\n<p>**\u6df7\u5408\u5e94\u7528\u5f00\u53d1**<\/p>\n<p>&#8211; \u5bf9\u4e8eCordova\uff1a<\/p>\n<p>  1. \u786e\u4fdd\u5df2\u5b89\u88c5Node.js\u3002<\/p>\n<p>  2. \u5b89\u88c5Cordova CLI\uff1a`npm install -g cordova`\u3002<\/p>\n<p>  3. \u521b\u5efaCordova\u9879\u76ee\uff1a`cordova create myApp com.example.myapp MyApp`\u3002<\/p>\n<p>  4. \u8f6c\u5230\u65b0\u521b\u5efa\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff1a`cd myApp`\u3002<\/p>\n<p>  5. \u6dfb\u52a0Android\u548ciOS\u5e73\u53f0\uff1a`cordova platform add android ios`\u3002<\/p>\n<p>  6. \u7f16\u5199HTML\u3001CSS\u548cJavaScript\u4ee3\u7801\uff0c\u66ff\u6362www\u6587\u4ef6\u5939\u4e2d\u7684\u73b0\u6709\u6587\u4ef6\uff0c\u5b9a\u5236\u4f60\u7684\u7f51\u7ad9APP\u3002<\/p>\n<p>  7. \u6784\u5efa\u548c\u8fd0\u884c\u5e94\u7528\uff1a`cordova run android`\u6216`cordova run ios`\u3002<\/p>\n<p>\u603b\u7ed3\uff1a\u901a\u8fc7\u4ee5\u4e0a\u539f\u751f\u5e94\u7528\u5f00\u53d1\u6216\u6df7\u5408\u5e94\u7528\u5f00\u53d1\u6280\u672f\uff0c\u4f60\u53ef\u4ee5\u5c06\u7f51\u7ad9\u751f\u6210APP\u3002\u6839\u636e\u5b9e\u9645\u9700\u6c42\u548c\u76ee\u6807\u5e73\u53f0\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u4ee5\u4fbf\u5728\u624b\u673a\u4e0a\u83b7\u5f97\u6700\u4f73\u4f53\u9a8c\u3002\u540c\u65f6\uff0c\u8bf7\u6ce8\u610f\uff0c\u4f7f\u7528Webview\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u6027\u80fd\u4e0a\u7684\u95ee\u9898\u6216\u9650\u5236\uff0c\u5728\u8bbe\u8ba1\u5e94\u7528\u7a0b\u5e8f\u65f6\u8bf7\u7ed9\u4e88\u5145\u5206\u8003\u8651\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e92\u8054\u7f51\u9886\u57df\uff0c\u5c06\u4e00\u4e2a\u7f51\u7ad9\u8f6c\u6362\u6210APP\u5e94\u7528\u662f\u4e00\u79cd\u5f88\u666e\u904d\u7684\u9700\u6c42\u3002\u901a\u5e38\uff0c\u7528\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6838\u5fc3\u6280\u672f\u662f\u79f0\u4e3aWebview\u7684\u7ec4\u4ef6\u3002Webview\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u5bb9\u5668\u6765\u52a0\u8f7d\u7f51\u9875\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u6210\u4e00\u4e2a\u5b9e\u9645\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[16250,132,22,25923,4257],"topic":[],"class_list":["post-20860","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-appphp","tag-132","tag-22","tag-app","tag-4257"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=20860"}],"version-history":[{"count":1,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20860\/revisions"}],"predecessor-version":[{"id":20883,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20860\/revisions\/20883"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=20860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=20860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=20860"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=20860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}