1

I'm building a hybrid application based on native iOS with parts over Cordova 3.1.0 (known as Cleaver component). The app is working with the sample index.html and it shows the "DEVICE IS READY" message (I suppose it means it's working fine). The problem now is how to add a custom plugin for communicating the native and the Phonegap components.

I've followed some tutorials:

http://moduscreate.com/building-a-custom-phonegap-plugin-for-ios/ http://devgirl.org/2013/09/17/how-to-write-a-phonegap-3-0-plugin-for-android/ (this one for Android)

I've tried installing the "connectivity" plugin on a base/canonical Cordova and copying the structure and the .m and .h to my project, and adding it's own config.xml part, but it didn't work.

Does anyone knows another resource for looking in, or someone else has been in the same situation?

Thanks!

Edited:

I've tested my custom plugin on a new created Cordova project and it works like a charm.

Edited #2:

Making a debug on the Phonegap Cleaver classes, most of it on the CDVViewController, I did realize that the UIWebView Delegate Methods are not being called:

- (void)webViewDidStartLoad:(UIWebView*)theWebView
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

Is there a way for it to reasign the delegate for them to be called?

4

1 回答 1

2

您可能已经找到了关于未调用 UIWebView 委托方法的问题的答案,但我想为可能偶然发现此页面的其他人提供答案(我在尝试解决此问题时多次遇到此帖子出去)。

我假设你的项目和我的一样使用 ARC,这就是问题所在。如果您按照以下说明操作: http ://cordova.apache.org/docs/en/3.3.0/guide_platforms_ios_webview.md.html#iOS%20WebViews_using_cdvviewcontroller

它告诉您“实例化一个新的 CDVViewController 并将其保留在某个地方,例如,一个类属性”,但在他们提供的示例中,他们不保留该变量。

相反,请确保将变量分配给属性:

@interface ViewController ()

@property (strong, nonatomic) CDVViewController *cdvViewController;

@end

@implementation ViewController

-(void)viewDidLoad
{
    [super viewDidLoad];

    self.cdvViewController = [CDVViewController new];
    [self.cdvViewController.view setFrame:self.view.frame];
    [self.view addSubview:self.cdvViewController.view];
}

现在将调用那些委托方法。希望这对其他人有帮助。

于 2013-12-31T13:29:38.397 回答