Skip to content

Commit

Permalink
WebViewJavascriptBridge 编译报错
Browse files Browse the repository at this point in the history
        // 加上下面这行代码, 编译就报错
//        _bridge = [WebViewJavascriptBridge
bridgeForWebView:self.webView];
  • Loading branch information
BigShow1949 committed Jul 31, 2017
1 parent b852ebb commit a7fcdba
Show file tree
Hide file tree
Showing 105 changed files with 7,393 additions and 539 deletions.
Binary file modified .DS_Store
Binary file not shown.
36 changes: 30 additions & 6 deletions BigShow1949.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
180E0EAF1DE7CEE300B5658A /* QRCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 180E0EAE1DE7CEE300B5658A /* QRCodeViewController.m */; };
181DC7CA1F2B396C0026C58B /* EXTSelectorChecking.m in Sources */ = {isa = PBXBuildFile; fileRef = 181DC7C71F2B396C0026C58B /* EXTSelectorChecking.m */; };
181DC7CB1F2B396C0026C58B /* Version in Resources */ = {isa = PBXBuildFile; fileRef = 181DC7C91F2B396C0026C58B /* Version */; };
1823996A1F0350AE005B58A0 /* Test.html in Resources */ = {isa = PBXBuildFile; fileRef = 182399691F0350AE005B58A0 /* Test.html */; };
1823996D1F0350D2005B58A0 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1823996C1F0350D2005B58A0 /* JavaScriptCore.framework */; };
182B9EA01DDEE61100FC1030 /* GCDViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 182B9E9F1DDEE61100FC1030 /* GCDViewController.m */; };
Expand All @@ -30,7 +32,7 @@
183699091DC325CE009AD5D5 /* YFAddMethodViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 183699081DC325CE009AD5D5 /* YFAddMethodViewController.m */; };
183717661F2B1FCA009D5882 /* JSCoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 183717651F2B1FCA009D5882 /* JSCoreViewController.m */; };
183717691F2B1FDD009D5882 /* JSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 183717681F2B1FDD009D5882 /* JSViewController.m */; };
1837176D1F2B214F009D5882 /* WebViewJavascriptBridgeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 1837176C1F2B214F009D5882 /* WebViewJavascriptBridgeVC.m */; };
1837176D1F2B214F009D5882 /* WebViewJSBridgeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 1837176C1F2B214F009D5882 /* WebViewJSBridgeVC.m */; };
183717741F2B2724009D5882 /* content1.css in Resources */ = {isa = PBXBuildFile; fileRef = 183717711F2B2724009D5882 /* content1.css */; };
183717751F2B2724009D5882 /* content1.html in Resources */ = {isa = PBXBuildFile; fileRef = 183717721F2B2724009D5882 /* content1.html */; };
183717761F2B2724009D5882 /* content1.js in Resources */ = {isa = PBXBuildFile; fileRef = 183717731F2B2724009D5882 /* content1.js */; };
Expand Down Expand Up @@ -684,6 +686,12 @@
/* Begin PBXFileReference section */
180E0EAD1DE7CEE300B5658A /* QRCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeViewController.h; sourceTree = "<group>"; };
180E0EAE1DE7CEE300B5658A /* QRCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRCodeViewController.m; sourceTree = "<group>"; };
181DC7C41F2B396C0026C58B /* EXTKeyPathCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTKeyPathCoding.h; sourceTree = "<group>"; };
181DC7C51F2B396C0026C58B /* EXTScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTScope.h; sourceTree = "<group>"; };
181DC7C61F2B396C0026C58B /* EXTSelectorChecking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTSelectorChecking.h; sourceTree = "<group>"; };
181DC7C71F2B396C0026C58B /* EXTSelectorChecking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXTSelectorChecking.m; sourceTree = "<group>"; };
181DC7C81F2B396C0026C58B /* metamacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metamacros.h; sourceTree = "<group>"; };
181DC7C91F2B396C0026C58B /* Version */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Version; sourceTree = "<group>"; };
182399691F0350AE005B58A0 /* Test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = Test.html; sourceTree = "<group>"; };
1823996C1F0350D2005B58A0 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
182B9E9E1DDEE61100FC1030 /* GCDViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -718,8 +726,8 @@
183717651F2B1FCA009D5882 /* JSCoreViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCoreViewController.m; sourceTree = "<group>"; };
183717671F2B1FDD009D5882 /* JSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSViewController.h; sourceTree = "<group>"; };
183717681F2B1FDD009D5882 /* JSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSViewController.m; sourceTree = "<group>"; };
1837176B1F2B214F009D5882 /* WebViewJavascriptBridgeVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeVC.h; sourceTree = "<group>"; };
1837176C1F2B214F009D5882 /* WebViewJavascriptBridgeVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeVC.m; sourceTree = "<group>"; };
1837176B1F2B214F009D5882 /* WebViewJSBridgeVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJSBridgeVC.h; sourceTree = "<group>"; };
1837176C1F2B214F009D5882 /* WebViewJSBridgeVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJSBridgeVC.m; sourceTree = "<group>"; };
183717711F2B2724009D5882 /* content1.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = content1.css; sourceTree = "<group>"; };
183717721F2B2724009D5882 /* content1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = content1.html; sourceTree = "<group>"; };
183717731F2B2724009D5882 /* content1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = content1.js; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1925,6 +1933,19 @@
path = QRCode;
sourceTree = "<group>";
};
181DC7C31F2B396C0026C58B /* extobjc */ = {
isa = PBXGroup;
children = (
181DC7C41F2B396C0026C58B /* EXTKeyPathCoding.h */,
181DC7C51F2B396C0026C58B /* EXTScope.h */,
181DC7C61F2B396C0026C58B /* EXTSelectorChecking.h */,
181DC7C71F2B396C0026C58B /* EXTSelectorChecking.m */,
181DC7C81F2B396C0026C58B /* metamacros.h */,
181DC7C91F2B396C0026C58B /* Version */,
);
path = extobjc;
sourceTree = "<group>";
};
182B9E9D1DDEE5F700FC1030 /* GCD */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2004,8 +2025,9 @@
1837176A1F2B20F0009D5882 /* WebViewJSBridge */ = {
isa = PBXGroup;
children = (
1837176B1F2B214F009D5882 /* WebViewJavascriptBridgeVC.h */,
1837176C1F2B214F009D5882 /* WebViewJavascriptBridgeVC.m */,
181DC7C31F2B396C0026C58B /* extobjc */,
1837176B1F2B214F009D5882 /* WebViewJSBridgeVC.h */,
1837176C1F2B214F009D5882 /* WebViewJSBridgeVC.m */,
183717711F2B2724009D5882 /* content1.css */,
183717721F2B2724009D5882 /* content1.html */,
183717731F2B2724009D5882 /* content1.js */,
Expand Down Expand Up @@ -5152,6 +5174,7 @@
18B487D21DAE3E2700ACD4BA /* YFKeepViewController.storyboard in Resources */,
18B4881F1DAE3E2800ACD4BA /* YFAnimationVC05.storyboard in Resources */,
18B487821DAE3E2700ACD4BA /* YFStackedPageVC.storyboard in Resources */,
181DC7CB1F2B396C0026C58B /* Version in Resources */,
18B4887B1DAE3E2800ACD4BA /* [email protected] in Resources */,
18B4875C1DAE3E2700ACD4BA /* dialCell2.xib in Resources */,
18B489031DAE3E2800ACD4BA /* FMDBBaseUseViewController.storyboard in Resources */,
Expand Down Expand Up @@ -5643,7 +5666,7 @@
18B4876D1DAE3E2700ACD4BA /* YFHomeLabelButton.m in Sources */,
18B489671DAE3E2800ACD4BA /* SDWebImageDownloaderOperation.m in Sources */,
18B489491DAE3E2800ACD4BA /* MASViewConstraint.m in Sources */,
1837176D1F2B214F009D5882 /* WebViewJavascriptBridgeVC.m in Sources */,
1837176D1F2B214F009D5882 /* WebViewJSBridgeVC.m in Sources */,
18B488A51DAE3E2800ACD4BA /* DraggableView.m in Sources */,
18B487E01DAE3E2700ACD4BA /* Case6ViewController.m in Sources */,
183803F31E5EDB7900CB3715 /* YFQuartz2DViewController.m in Sources */,
Expand Down Expand Up @@ -5747,6 +5770,7 @@
18B489021DAE3E2800ACD4BA /* FMDBBaseUseViewController.m in Sources */,
180E0EAF1DE7CEE300B5658A /* QRCodeViewController.m in Sources */,
18B489241DAE3E2800ACD4BA /* YFHanoiVC.mm in Sources */,
181DC7CA1F2B396C0026C58B /* EXTSelectorChecking.m in Sources */,
18B487A51DAE3E2700ACD4BA /* ITRAirSideMenu.m in Sources */,
18B489581DAE3E2800ACD4BA /* NSObject+MJMember.m in Sources */,
18B4891E1DAE3E2800ACD4BA /* MGJRequestManager.m in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ - (void)viewDidLoad {


[self setupDataArr:@[@[@"JSCore",@"JSCoreViewController"],
]];
@[@"JSBridge使用",@"WebViewJSBridgeVC"]]];

}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

#import <UIKit/UIKit.h>

@interface WebViewJavascriptBridgeVC : UIViewController
@interface WebViewJSBridgeVC : UIViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
//
// WebViewJavascriptBridgeVC.m
// BigShow1949
//
// Created by apple on 17/7/28.
// Copyright © 2017年 BigShowCompany. All rights reserved.
//

#import "WebViewJSBridgeVC.h"
#import "WebViewJavascriptBridge.h"
#import "EXTScope.h"
#import "SDWebImageManager.h"

static NSString * const onLoadedMethodJSName = @"onLoaded";
static NSString * const browImageMethodJSName = @"browImage";
static NSString * const imageDownLoadCompletedJSName = @"imageDownLoadCompleted";


@interface WebViewJSBridgeVC ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) WebViewJavascriptBridge *bridge;
@property (nonatomic, strong) NSMutableArray *imageFilePaths;
@end

/* ============ 调用第三方 WebViewJavascriptBridge ==========*/
@implementation WebViewJSBridgeVC

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setEdgesForExtendedLayout:UIRectEdgeNone];
self.view.backgroundColor = [UIColor whiteColor];

self.title = @"JSBridgeVC";

NSString *htmlFilePath = [[NSBundle mainBundle]pathForResource:@"content1" ofType:@"html"];
NSString *htmlContentString = [NSString stringWithContentsOfFile:htmlFilePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:htmlContentString baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[self.view addSubview:self.webView];

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_back"] style:UIBarButtonItemStylePlain target:self action:@selector(onBackAction)];

}

- (void)onBackAction{

if([_webView canGoBack]){
[_webView goBack];
}
else{
[self.navigationController popViewControllerAnimated:YES];
}
}

- (UIWebView *)webView{

if (!_webView) {
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, YFScreen.width, YFScreen.height - 64)];
_webView.layer.borderColor = [UIColor redColor].CGColor;
_webView.layer.borderWidth = 1;
}
return _webView;
}

- (WebViewJavascriptBridge *)bridge{
if (!_bridge) {
// [WebViewJavascriptBridge enableLogging];
// 加上下面这行代码, 编译就报错
// _bridge = [WebViewJavascriptBridge bridgeForWebView:self.webView];
// [_bridge setWebViewDelegate:self];

}
return _bridge;
}


/**
注册Native方法,响应JS调用
*/
/*
- (void)registerNativeHandler{
//页面加载
@weakify(self);
[self.bridge registerHandler:onLoadedMethodJSName handler:^(NSArray *imageInfos, WVJBResponseCallback responseCallback) {
//js传过来的数据
NSLog(@"imageInfos = %@", imageInfos);
@strongify(self);
[self downloadImagesWithInfos:imageInfos];
}];
//点击图片
[self.bridge registerHandler:browImageMethodJSName handler:^(NSArray *dataArray, WVJBResponseCallback responseCallback) {
@strongify(self);
NSLog(@"dataArray = %@", dataArray);
NSInteger index = [dataArray[0] integerValue];
// XLPhotoBrowser *imageBrowser = [XLPhotoBrowser showPhotoBrowserWithCurrentImageIndex:index imageCount:[self.imageFilePaths count] datasource:self];
// imageBrowser.browserStyle = XLPhotoBrowserStyleSimple;
}];
}
*/

/**
在本地下载多张图片,图片下载成功通知js处理
*/
/*
- (void)downloadImagesWithInfos:(NSArray *)imageInfos{
[imageInfos enumerateObjectsUsingBlock:^(NSArray *info, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *imageCachePath = [[SDImageCache sharedImageCache] defaultCachePathForKey:info[1]];
[self.imageFilePaths addObject:imageCachePath];
}];
for (int i = 0; i < [imageInfos count]; i++) {
NSArray *imageInfo = [imageInfos objectAtIndex:i];
NSUInteger imageIndex = [imageInfo[0] integerValue];
[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:imageInfo[1]] options:SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (!image) {
return;
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *imageCachePath = [[SDImageCache sharedImageCache] defaultCachePathForKey:[imageURL absoluteString]];
//通知js的imagesDownloadComplete方法处理
[self.bridge callHandler:imageDownLoadCompletedJSName data:@[[NSNumber numberWithInteger:imageIndex],imageCachePath] responseCallback:nil];
});
}];
}
}
*/

@end

This file was deleted.

Loading

0 comments on commit a7fcdba

Please sign in to comment.