在启动应用程序时,我正在WKWebView中加载https://www.google.com。应用程序有一个按钮,单击该按钮后,应用程序将从文档目录加载本地html页面。我使用以下代码加载html页面。
let destPath = NSSearchPathForDirectoriesInDomains(.documentDirectory,
.userDomainMask,
true)[0]
let fileName = "Demo.html"
let fullDestPath = URL(fileURLWithPath: destPath)
.appendingPathComponent(fileName)
self.webView! .loadFileURL(fullDestPath, allowingReadAccessTo: fullDestPath)
Run Code Online (Sandbox Code Playgroud)
该代码一直运行到iOS 12.1.4,但是在iOS 12.2中,它没有加载html页面并抛出错误
ProvisionalPageProxy::didFailProvisionalLoadForFrame: pageID = 1, frameID = 1, navigationID = 2
Run Code Online (Sandbox Code Playgroud) 我正在本地消息传递主机上工作。我可以使用 api 启动我的自定义应用程序
var port = chrome.runtime.connectNative('com.my_company.my_application');
Run Code Online (Sandbox Code Playgroud)
我可以使用 api 将消息发布到我的自定义应用程序
port.postMessage({ text: "Hello, my_application" });
Run Code Online (Sandbox Code Playgroud)
我知道他们使用输入/输出流来发送和接收消息。我的本机应用程序(c 或 c++ exe)应该如何获得有关接收到的消息的通知,我应该处理哪个函数/事件来接收消息。
我正在使用此函数将cv :: mat转换为UIImage.
-(UIImage *)UIImageFromCVMat:(cv::Mat)cvMat
{
NSData *data = [NSData dataWithBytes:cvMat.data length:cvMat.elemSize()*cvMat.total()];
CGColorSpaceRef colorSpace;
if (cvMat.elemSize() == 1) {
colorSpace = CGColorSpaceCreateDeviceGray();
} else {
colorSpace = CGColorSpaceCreateDeviceRGB();
}
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data);
// Creating CGImage from cv::Mat
CGImageRef imageRef = CGImageCreate(cvMat.cols, //width
cvMat.rows, //height
8, //bits per component
8 * cvMat.elemSize(), //bits per pixel
cvMat.step[0], //bytesPerRow
colorSpace, //colorspace
kCGImageAlphaNone|kCGBitmapByteOrderDefault,// bitmap info
provider, //CGDataProviderRef
NULL, //decode
false, //should interpolate
kCGRenderingIntentDefault //intent
);
// Getting UIImage from CGImage
UIImage *finalImage = …Run Code Online (Sandbox Code Playgroud) 我正在运行Native messaging示例应用程序.(http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/).
我添加了注册表项
HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.google.chrome.example.echo
Run Code Online (Sandbox Code Playgroud)
当我连接到本机主机时,我收到错误:
Failed to connect: Access to the specified native messaging host is forbidden.
Run Code Online (Sandbox Code Playgroud) javascript google-chrome google-chrome-extension chrome-native-messaging