HTML5   发布时间:2022-04-25  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了phonegap运行www包遇到的问题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

最近公司一直要求学习phonegap打包项目   我也是第一次开始接触   用了几下  感觉还不错吧   主要是HTML5+JS的代码

在此期间  我遇到了很多的问题

问题1、老大给了我个www包叫我用iPhone手机运行一下 看一下效果   老大可能也不大懂iOS(老大是搞安卓的)   说用webView加载  于是我就写了这么些代码

//加载本地的HTML
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,self.view.bounds.size.width,self.view.bounds.size.height)];
    NSString *htmlFile = [[NSBundle mainBundle] pathForresource:@"login" ofType:@"html"];
    NSString* htmlString = [NSString StringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
    NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];
    
    [webView loadHTMLString:htmlString baseURL:baseURL];
    // 把baseURL知道bundle的Url,就能调用bundle里的其他文件了,图片音乐什么的
    [self.view addSubview:webView];


这样做了一下  界面好像是可以显示出来  可是遇到了许多问题  于是我就另辟蹊径   

在网上找了各种资料   发现  原来用phonegap运行www包得时候  Xcode是不用写一句代码的  其中

config.xml是全局的配置文件  把要显示的界面写在<content src="login/login.html" />  这里面  我这里是登陆界面

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 diStributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License,Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in wriTing,software diStributed under the License is diStributed on an
 "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND,either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->
<widget xmlns     = "http://www.w3.org/ns/widgets"
        id        = "io.cordova.HelloCordova"
        version   = "2.0.0">
    <name>Hello Cordova</name>

    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>

    <author href="http://cordova.io" email="dev@cordova.apache.org">
        Apache Cordova Team
    </author>

    <access origin="*"/>

    <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
    <content src="login/login.html" />

    <!-- Preferences for iOS -->
    <preference name="AllowInlineMediaPlayBACk" value="false" />
    <preference name="AutoHideSplashScreen" value="true" />
    <preference name="BACkupWebStorage" value="cloud" />


这样一些  运行时会出现三个弹框(因为www包是老大发给我的,他是搞安卓的)  一次点击取消也可得到想要的效果   任务也可以完成   可是点击三次取消按钮  谁会不觉得烦呢

附上图片   图片1:

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



图片2:

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



图片3:

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



对于这个问题老大也说不出来   我也是百思不得其解   后来在栈溢出上找到一点线索  我试了半天  终于成功了

栈溢出上面说把安卓的什么东西带了进来  说的比较模糊  我仔细看了下工程  发现工程中有两个这样的文件

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



于是我把包里面的一个文件移出到了桌面   再次运行程序  发现没有任何问题   大功告成了

运行效果图如下

1、

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



2、

@H_673_47@@H_673_47@phonegap运行www包遇到的问题



3、

@H_673_47@@H_673_47@phonegap运行www包遇到的问题

大佬总结

以上是大佬教程为你收集整理的phonegap运行www包遇到的问题全部内容,希望文章能够帮你解决phonegap运行www包遇到的问题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。