android和iOS中打包html5
来源:互联网 发布:手机淘宝店铺怎么收藏 编辑:程序博客网 时间:2024/06/08 07:24
目前有一个项目想使用html5实现业务逻辑,同时发布成android和iOS 移动app,这个涉及到如何将这些html、图片、js打包进app并在webview中装载html。下面是具体细节:
一、android打包html5
将html相关的代码拷贝到assets目录下,如下图所示:
那么如何使用呢?如下所示即可访问index.html,使用WebView打开即可。
private String url = "file:///android_asset/www/index.html";
二、iOS打包html5
将html相关的代码拷贝到一个目录(如www),然后将该目录重命名为www.bundle,并拖放到xcode工程中。如下图所示:
如何使用这个呢?如下所示代码可以访问index.html:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; NSString *bundlePath = [[ NSBundle mainBundle ]. resourcePath stringByAppendingPathComponent : @"www.bundle" ]; NSBundle *bundle = [ NSBundle bundleWithPath :bundlePath]; NSString* path = [bundle pathForResource:@"index" ofType:@"html"]; ZZQWebViewController *webView = [[ZZQWebViewController alloc]init]; webView.url = path; webView.htmlStr = @""; webView.title = @""; self.window.rootViewController = webView; [self.window makeKeyAndVisible]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; return YES;}
0 0
- android和iOS中打包html5
- HTML5游戏Android再次编译以及iOS编译和实现打包iPa笔录
- Android和iOS在新版本中助力HTML5
- Android和iOS在新版本中助力HTML5
- HTML5+ Android打包证书
- weexpack 创建项目, 打包Android 和 ios
- Android中代码混淆和打包
- IOS ,Android + html5
- osx下用phonegap搭建ios和android打包服务
- Quick-Cocos2d-x打包iOS和Android流程
- 暗黑战神客户端(IOS和Android)打包教程
- ionic2完整-签名android和ios App打包上架
- iOS中使用Fastlane实现自动化打包和发布
- iOS中使用Fastlane实现自动化打包和发布
- iOS中使用Fastlane实现自动化打包和发布
- iOS中使用Fastlane实现自动化打包和发布
- iOS中使用Fastlane实现自动化打包和发布
- iOS中使用Fastlane实现自动化打包和发布
- Oracle 查询死锁语句
- 一篇文章理解所有android关于存储的方法
- 《Java编程思想》学习笔记(第四章): 流程控制语句
- 不得不知那些Android小经验 (转)
- Again to learn java重学java
- android和iOS中打包html5
- Cocos2d-Lua之table的遍历
- 110-First Missing Positive
- Oracle生成32位GUID方法
- 数据库范式
- LiveReload插件安装、配置及用法
- Laravel Eloquent – 快速复制数据
- 框架 day55 BOS项目练习(工作流,activiti入门)
- RPC原理(1)