我尝试使用Cleaver,即PhoneGap/Cordova作为现有iOS应用程序的一个组件.我按照一步一步的指导两次,没有成功.
我的应用程序可以轻松实例化Web视图,我可以使用该stringbyevaluatingjavascriptfromstring方法将内容传递给它,但是一旦我尝试访问PhoneGap API(navigator.compass, navigator.network, ...),似乎没有任何工作.console.log(navigator)没有显示Cordova对象的迹象(console.log不输出任何东西是Xcode,我正在使用http://debug.phonegap.com/).该deviceready事件也未被触发.
在我的html文件中,我包含cordova-1.7.0rc1.js我从另一个项目复制的PhoneGap js文件(因为/www当您使用PhoneGap作为组件时,文件夹丢失).
我的ViewController.h进口<Cordova/CDVViewController.h>.在这里我的ViewController.m
//
// ViewController.m
// CordovaComponent
//
#import "ViewController.h"
@interface ViewController (){
CDVViewController *cdvViewController ;
}
@end
@implementation ViewController
- (void)pushPhoneGap:(id)sender {
cdvViewController = [[CDVViewController alloc] init];
cdvViewController.wwwFolderName = @"www";
cdvViewController.startPage = @"index.html";
cdvViewController.view.frame = self.view.bounds;
cdvViewController.webView.delegate = self;
[self.navigationController pushViewController:cdvViewController animated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do …Run Code Online (Sandbox Code Playgroud)