JSPatch下发笔记9

简介: JSPatch下发笔记9

OC代码:

-(void)rightBarButtonItemPressed{
    NSString *js = @"document.getElementsByTagName('meta')['Description']['content']";
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"neisha_logo"]];
    imageView.hidden=YES;
    [self.view addSubview:imageView];
    UIImage *image=[[SDImageCache sharedImageCache] imageFromDiskCacheForKey:_imageUrl];
        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [imageView sd_setImageWithURL:_imageUrl placeholderImage:[UIImage new] andType:3 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
            [self.webView.wkWebView evaluateJavaScript:js completionHandler:^(id _Nullable desc, NSError * _Nullable error) {
                [[ThirdShareManager sharedInstance] shareItemWithTitle:_title description:desc image:image url:_url controller:self block:nil];
            }];
        }];
}


JS代码:

rightBarButtonItemPressed: function() {
            var js = "document.getElementsByTagName\('meta')['Description']['content']";
            var imageView = UIImageView.alloc().initWithImage(UIImage.imageNamed("neisha_logo"));
            imageView.setHidden(1);
            self.view().addSubview(imageView);
            var _imageUrl = self.valueForKey("_imageUrl");
            var _url = self.valueForKey("_url");
            var _title = self.valueForKey("_title");
            console.log(_imageUrl);
            var image = SDImageCache.sharedImageCache().imageFromDiskCacheForKey(_imageUrl);
            MBProgressHUD.showHUDAddedTo_animated(self.view(), 1);
            imageView.sd__setImageWithURL_placeholderImage_andType_completed(_imageUrl, UIImage.new(), 3, block("void, UIImage*, NSError*, SDImageCacheType, NSURL*", function(image, error, cacheType, imageURL) {
                console.log(image);
                MBProgressHUD.hideAllHUDsForView_animated(self.view(), 1);
                self.webView().wkWebView().evaluateJavaScript_completionHandler(js, block("void, id, NSError", function(desc, error) {
                ThirdShareManager.sharedInstance().shareItemWithTitle_description_image_url_controller_block(_title, desc, image, _url, self, null);
                }));
            }));
            }


注:

OC中的字符串@"document.getElementsByTagName('meta')['Description']['content']";  在JS中要写成"document.getElementsByTagName('meta')['Description']['content']";

()前面要加上转义字符\

目录
相关文章
|
2月前
|
JavaScript 前端开发
Vue、ElementUI配合Node、multiparty模块实现图片上传并反显_小demo
如何使用Vue和Element UI配合Node.js及multiparty模块实现图片上传并反显的功能,包括前端的Element UI组件配置和后端的Node.js服务端代码实现。
41 1
Vue、ElementUI配合Node、multiparty模块实现图片上传并反显_小demo
|
6月前
|
安全
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
103 0
|
算法
vue2-patch流程分析
我们在上篇文章分析了虚拟节点的创建及渲染流程,其中也有简单分析了 patch 过程,但是对于新旧节点的对比逻没有去仔细分析,所以我们打算好好梳理下 patch 的整个流程。
|
Web App开发 JavaScript iOS开发
JSPatch 断点调试
JSPatch 断点调试
145 0
JSPatch 断点调试
|
JavaScript
JSPatch下发笔记1
JSPatch下发笔记1
117 0
|
JavaScript
JSPatch下发笔记2
JSPatch下发笔记2
143 0
|
JavaScript
JSPatch下发笔记7
JSPatch下发笔记7
133 0
JSPatch下发笔记5
JSPatch下发笔记5
113 0
|
JavaScript
JSPatch下发笔记8
JSPatch下发笔记8
130 0
|
JavaScript
JSPatch下发笔记10
JSPatch下发笔记10
110 0
下一篇
无影云桌面