iOS:HBuilder导出ios项目并打包,本地打包运行

大腿Plus 2018年4月2日14:14:44iOS之项目开发评论538阅读模式

这里只介绍HBuilder导出iOS App 项目的简单过程文章源自大腿Plus-https://www.shijunzh.com/archives/680

首先打开HBuilder 点击菜单中的发行-生成本地打包app资源文章源自大腿Plus-https://www.shijunzh.com/archives/680

iOS:HBuilder导出ios项目并打包,本地打包运行

然后,新建一个Xcode工程,新建一个bundle文件,将导出来的App资源放到bundle文件内,具体方法是打开包内容,右键显示包内容,将App资源拖到bundle里面。文章源自大腿Plus-https://www.shijunzh.com/archives/680

iOS:HBuilder导出ios项目并打包,本地打包运行

iOS:HBuilder导出ios项目并打包,本地打包运行文章源自大腿Plus-https://www.shijunzh.com/archives/680

然后在Xcode工程里写一个View来启动显示H5的内容。文章源自大腿Plus-https://www.shijunzh.com/archives/680

//
//  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.shijunzh.com/archives/680

大腿Plus
  • 本文由 发表于 2018年4月2日14:14:44
  • 转载请务必保留本文链接:https://www.shijunzh.com/archives/680

发表评论