He intentado usar Cleaver, es decir PhoneGap/Cordova como un componente de una aplicación iOS existente. Seguí this step by step guide dos veces, sin éxito.Cleaver (PhoneGap/Cordova como componente) no funciona en iOS
Mi aplicación puede instanciar fácilmente una vista web, y puedo pasarle contenido usando el método stringbyevaluatingjavascriptfromstring
, pero tan pronto como intento acceder a PhoneGap API (navigator.compass, navigator.network, ...
), nada parece funcionar. console.log(navigator)
no muestra signos de objetos Cordova (console.log
no muestra nada es Xcode, estoy usando http://debug.phonegap.com/). El evento deviceready
tampoco se desencadena.
En mi archivo html, incluyo el archivo PhoneGap js cordova-1.7.0rc1.js
que copié de otro proyecto (ya que falta la carpeta /www
cuando usa PhoneGap como componente).
Mi ViewController.h
importaciones <Cordova/CDVViewController.h>
. Aquí mi 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
¿Tiene usted una idea de lo que está pasando? ¡Cualquier ayuda sería muy apreciada!
Hola, si esta línea no se agrega, la función webViewDidFinishLoad no se puede activar? – red23jordan