I tried using Cleaver, i.e. PhoneGap / Cordova, as a component of an existing iOS application. I followed this walkthrough twice without success.
My application can easily create a web view, and I can transfer content to it using the stringbyevaluatingjavascriptfromstring method, but as soon as I try to access the PhoneGap API ( navigator.compass, navigator.network, ... ) nothing works. console.log(navigator) does not show any signs of Cordoba objects ( console.log does not display anything, this is Xcode, I use http://debug.phonegap.com/ ). The deviceready event also does not deviceready .
In my html file, I include the PhoneGap file js cordova-1.7.0rc1.js , which I copied from another project (since /www missing a folder when you use PhoneGap as a component).
My ViewController.h imports <Cordova/CDVViewController.h> . Here is my 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 any additional setup after loading the view, typically from a nib. UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:@"Push PhoneGap view" forState:UIControlStateNormal]; [button addTarget:self action:@selector(pushPhoneGap:) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(60, 50, 200., 50.); [self.view addSubview:button]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } - (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *jsReturn = [cdvViewController.webView stringByEvaluatingJavaScriptFromString:@"setArray([1, 1, 2, 3, 5, 8, 13, 21, 34, 1]);"]; NSLog(jsReturn); } @end
Do you have any idea what is going on? Any help would be greatly appreciated!
ios cordova
Brad flower
source share