拷貝資源檔案
- 将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];