webview使用JSContext 向网页js注入时时机要选为网页加载完成后即放在

-(void)webViewDidFinishLoad:(UIWebView *)webView 方法

-(void)webViewDidFinishLoad:(UIWebView *)webView{

    context = [self.webView  valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
__block __weak DetailWebController *weakSelf = self; context[@"ios_follow"] = ^() {
NSArray *args = [JSContext currentArguments];
BOOL toBool = [((JSValue *)args.firstObject) toBool];
NSString *toString = [((JSValue *)args.lastObject) toString];
if (toBool) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf getChaseDramaWithID:toString];
});
}else{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf getCancelChaseDramaWithID:toString];
});
}
};
context[@"ios_score"] = ^() {
NSArray *args = [JSContext currentArguments];
JSValue * value = args.firstObject;
NSInteger score = [value toUInt32];
[weakSelf setScoreWithScore:score];
};
}

最新文章

  1. dede判断当前文章
  2. VR原理讲解及开发入门
  3. java异常笔记
  4. 上传文件被nginx全部缓存的问题
  5. word开发遇到的问题
  6. [强连通分量] POJ 2186 Popular Cows
  7. 基于 backbone的弹窗插件
  8. (spring-第7回【IoC基础篇】)BeanDefinition的载入与解析&&spring.schemas、spring.handlers的使用
  9. .NET开源工作流RoadFlow-系统布署及注意事项
  10. Zclip复制页面内容到剪贴板兼容各浏览器
  11. Android ServiceConnection
  12. 下载jdk-api 1.7文档
  13. Android窗口管理服务WindowManagerService对输入法窗口(Input Method Window)的管理分析
  14. ZOJ 3195 Design the city 题解
  15. LeetCode 题目总结/分类
  16. Linux 学习记录 四(Bash 和 Shell scirpt)
  17. MyBatis(三):数据库查询结果不为空,但是使用MyBatis框架查询为空问题
  18. mybatis中使用常量
  19. Data - 关于大数据
  20. 实现ScrollviewSupportMaxHeight

热门文章

  1. 自动化mobile测试
  2. Hadoop集群(第10期副刊)_常用MySQL数据库命令
  3. java 的UUID的具体用法
  4. 简单了解JAVA8的新特性
  5. Warning: Using innodb_additional_mem_pool_size is DEPRECATED
  6. gcc与g++
  7. BZOJ 3306 树
  8. BZOJ 4004 装备购买
  9. 【Java】从域名得到ip
  10. aspose.word使用简单方法