拷贝资源文件
- 将cordova的iOS平台目录ios中的文件拷贝到原生项目根目录
- cordova的iOS平台目录ios中对应的文件
- CordovaLib
- HelloWorld(项目名称)/config.xml
- HelloWorld(项目名称)/Plugins
- www
- 拷贝到原生项目根目录对应的文件
原生项目配置
添加资源文件
- 添加CordovaLib.xcodeproj
- 添加www
- 添加Plugins
- 添加config.xml
- 添加后的目录
配置Build Settings
- Build Settings -> Other Linker Flags -> -all_load -ObjC
配置Build Phases
- Dependencies添加CordovaLib
- Link Binary With Libraties添加libCordova.a
设置显示指定cordova页面
- 新建WebViewController,继承自CDVViewController
- 将WebViewController.h中的#import <Cordova/Cordova.h>改为#import <Cordova/CDV.h>
- 设置加载指定的cordova页面
WebViewController *vc = [[WebViewController alloc] init];
vc.startPage = @"home.html";
[self.navigationController pushViewController:vc animated:YES];