这里只介绍HBuilder导出iOS App 项目的简单过程
首先打开HBuilder 点击菜单中的发行-生成本地打包app资源文章源自大腿Plus-https://www.zhaoshijun.com/archives/680
然后,新建一个Xcode工程,新建一个bundle文件,将导出来的App资源放到bundle文件内,具体方法是打开包内容,右键显示包内容,将App资源拖到bundle里面。文章源自大腿Plus-https://www.zhaoshijun.com/archives/680
文章源自大腿Plus-https://www.zhaoshijun.com/archives/680
然后在Xcode工程里写一个View来启动显示H5的内容。文章源自大腿Plus-https://www.zhaoshijun.com/archives/680
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// // ViewController.m // tour // // Created by apple on 17/8/22. // Copyright © 2017年 zhichaoniao. All rights reserved. // #import "ViewController.h" @interface ViewController () @property (nonatomic, strong, readwrite) UIWebView *webView; @end @implementation ViewController - (UIWebView *)webView { if (!_webView) { _webView = [[UIWebView alloc]initWithFrame:self.view.bounds]; _webView.mediaPlaybackRequiresUserAction = NO; _webView.scalesPageToFit = YES; _webView.scrollView.scrollEnabled = NO; } return _webView; } - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.webView]; // Do any additional setup after loading the view, typically from a nib. NSString * bundlePath = [[ NSBundle mainBundle] pathForResource:@"360" ofType :@"bundle"]; NSString *filePath = [bundlePath stringByAppendingPathComponent :@"index.html"]; NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; [self.webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:filePath]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end |
上面的代码里pathForResource是bundle的名字,后面的ofType是bundle的拓展名,stringByAppendingPathComponent是H5的启动页面。文章源自大腿Plus-https://www.zhaoshijun.com/archives/680 文章源自大腿Plus-https://www.zhaoshijun.com/archives/680
我的微信
微信扫一扫
shijun_z
我的QQ
QQ扫一扫
846207670
评论