简体   繁体   English

如何在插件中访问embbeded cordova webview?

[英]How to access embbeded cordova webview in plugin?

I made a controller that inherit embedded cordova webview. 我制作了一个继承嵌入式cordova webview的控制器。 And I created a custom plugin. 我创建了一个自定义插件。

javascript call custom plugin method. javascript调用自定义插件方法。

I want to access my controller that inherit embedded cordova webview in plugin method. 我想访问我的控制器,在插件方法中继承嵌入式cordova webview。

// MyPlugin.m
@import "MyPlugin.h"
@import "MyController.h"

@implementation myPlugin
- (void) myPluginMethod: (CDVInvokedUrlCommand *)command {
    // How to access my controller that inherit embedded cordova webview in this.
}

In a regular plugin you can get the viewController with 在常规插件中,您可以使用viewController

self.viewController

But, as you are using an embedded cordova webview it might not work. 但是,当您使用嵌入式cordova webview时,它可能无法正常工作。

So, if it doesn't work you can always get the rootViewController like this: 所以,如果它不起作用,你总是可以得到这样的rootViewController:

UIViewController *vc = [[[UIApplication sharedApplication] keyWindow] rootViewController]; 

If you want to access the webView just use 如果你想访问webView只是使用

self.webView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM