From 40f2118274ad04b9e0e656722c68b09d180efb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=A4=A7=E5=AE=9D?= Date: Mon, 4 May 2020 18:31:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4webview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlocksKit.xcodeproj/project.pbxproj | 13 +---- BlocksKit/UIKit/UIWebView+BlocksKit.h | 36 ------------ BlocksKit/UIKit/UIWebView+BlocksKit.m | 80 --------------------------- 3 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 BlocksKit/UIKit/UIWebView+BlocksKit.h delete mode 100644 BlocksKit/UIKit/UIWebView+BlocksKit.m diff --git a/BlocksKit.xcodeproj/project.pbxproj b/BlocksKit.xcodeproj/project.pbxproj index c08aa3775..7024956ce 100644 --- a/BlocksKit.xcodeproj/project.pbxproj +++ b/BlocksKit.xcodeproj/project.pbxproj @@ -158,9 +158,6 @@ DB4CA5001B3A6657004B70F8 /* UIView+BlocksKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DB4CA4A11B3A6657004B70F8 /* UIView+BlocksKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB4CA5021B3A6657004B70F8 /* UIView+BlocksKit.m in Sources */ = {isa = PBXBuildFile; fileRef = DB4CA4A21B3A6657004B70F8 /* UIView+BlocksKit.m */; }; DB4CA5031B3A6657004B70F8 /* UIView+BlocksKit.m in Sources */ = {isa = PBXBuildFile; fileRef = DB4CA4A21B3A6657004B70F8 /* UIView+BlocksKit.m */; }; - DB4CA5051B3A6657004B70F8 /* UIWebView+BlocksKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DB4CA4A31B3A6657004B70F8 /* UIWebView+BlocksKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DB4CA5071B3A6657004B70F8 /* UIWebView+BlocksKit.m in Sources */ = {isa = PBXBuildFile; fileRef = DB4CA4A41B3A6657004B70F8 /* UIWebView+BlocksKit.m */; }; - DB4CA5081B3A6657004B70F8 /* UIWebView+BlocksKit.m in Sources */ = {isa = PBXBuildFile; fileRef = DB4CA4A41B3A6657004B70F8 /* UIWebView+BlocksKit.m */; }; DB4CA50D1B3A6720004B70F8 /* BlocksKit+MessageUI.h in Headers */ = {isa = PBXBuildFile; fileRef = DB4CA5091B3A6720004B70F8 /* BlocksKit+MessageUI.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB4CA50F1B3A6720004B70F8 /* BlocksKit+QuickLook.h in Headers */ = {isa = PBXBuildFile; fileRef = DB4CA50A1B3A6720004B70F8 /* BlocksKit+QuickLook.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB4CA5111B3A6720004B70F8 /* BlocksKit+UIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DB4CA50B1B3A6720004B70F8 /* BlocksKit+UIKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -277,7 +274,6 @@ DB5C6C7B1C5200B200778E5F /* UITextField+BlocksKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DB4CA49F1B3A6657004B70F8 /* UITextField+BlocksKit.h */; }; DB5C6C7C1C5200B200778E5F /* UITextView+BlocksKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DB5C6C4E1C52009700778E5F /* UITextView+BlocksKit.h */; }; DB5C6C7D1C5200B200778E5F /* UIView+BlocksKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DB4CA4A11B3A6657004B70F8 /* UIView+BlocksKit.h */; }; - DB5C6C7E1C5200B200778E5F /* UIWebView+BlocksKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DB4CA4A31B3A6657004B70F8 /* UIWebView+BlocksKit.h */; }; DB9B961C1B3A52A700940D20 /* BlocksKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DB9B961B1B3A52A700940D20 /* BlocksKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB9B96231B3A52A700940D20 /* BlocksKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB9B96181B3A52A700940D20 /* BlocksKit.framework */; }; DB9B96411B3A52E500940D20 /* BlocksKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB9B96371B3A52E500940D20 /* BlocksKit.framework */; }; @@ -371,7 +367,6 @@ DB5C6C7B1C5200B200778E5F /* UITextField+BlocksKit.h in CopyFiles */, DB5C6C7C1C5200B200778E5F /* UITextView+BlocksKit.h in CopyFiles */, DB5C6C7D1C5200B200778E5F /* UIView+BlocksKit.h in CopyFiles */, - DB5C6C7E1C5200B200778E5F /* UIWebView+BlocksKit.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -458,8 +453,6 @@ DB4CA4A01B3A6657004B70F8 /* UITextField+BlocksKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextField+BlocksKit.m"; sourceTree = ""; }; DB4CA4A11B3A6657004B70F8 /* UIView+BlocksKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BlocksKit.h"; sourceTree = ""; }; DB4CA4A21B3A6657004B70F8 /* UIView+BlocksKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BlocksKit.m"; sourceTree = ""; }; - DB4CA4A31B3A6657004B70F8 /* UIWebView+BlocksKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+BlocksKit.h"; sourceTree = ""; }; - DB4CA4A41B3A6657004B70F8 /* UIWebView+BlocksKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+BlocksKit.m"; sourceTree = ""; }; DB4CA5091B3A6720004B70F8 /* BlocksKit+MessageUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BlocksKit+MessageUI.h"; sourceTree = ""; }; DB4CA50A1B3A6720004B70F8 /* BlocksKit+QuickLook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BlocksKit+QuickLook.h"; sourceTree = ""; }; DB4CA50B1B3A6720004B70F8 /* BlocksKit+UIKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BlocksKit+UIKit.h"; sourceTree = ""; }; @@ -694,8 +687,6 @@ DB5C6C4F1C52009700778E5F /* UITextView+BlocksKit.m */, DB4CA4A11B3A6657004B70F8 /* UIView+BlocksKit.h */, DB4CA4A21B3A6657004B70F8 /* UIView+BlocksKit.m */, - DB4CA4A31B3A6657004B70F8 /* UIWebView+BlocksKit.h */, - DB4CA4A41B3A6657004B70F8 /* UIWebView+BlocksKit.m */, ); path = UIKit; sourceTree = ""; @@ -917,7 +908,6 @@ DB4CA4C41B3A6657004B70F8 /* MFMailComposeViewController+BlocksKit.h in Headers */, DB4CA43D1B3A662A004B70F8 /* NSMapTable+BlocksKit.h in Headers */, DB4CA4291B3A662A004B70F8 /* NSArray+BlocksKit.h in Headers */, - DB4CA5051B3A6657004B70F8 /* UIWebView+BlocksKit.h in Headers */, DB4CA4E21B3A6657004B70F8 /* UIControl+BlocksKit.h in Headers */, DB4CA5111B3A6720004B70F8 /* BlocksKit+UIKit.h in Headers */, DB4CA4BA1B3A6657004B70F8 /* NSObject+A2BlockDelegate.h in Headers */, @@ -1107,6 +1097,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -1189,7 +1180,6 @@ DB4CA4D51B3A6657004B70F8 /* UIActionSheet+BlocksKit.m in Sources */, DB4CA4CB1B3A6657004B70F8 /* MFMessageComposeViewController+BlocksKit.m in Sources */, DB4CA4EE1B3A6657004B70F8 /* UIImage+BlocksKit.m in Sources */, - DB4CA5071B3A6657004B70F8 /* UIWebView+BlocksKit.m in Sources */, DB4CA4621B3A662A004B70F8 /* NSObject+BKBlockExecution.m in Sources */, DB4CA4FD1B3A6657004B70F8 /* UITextField+BlocksKit.m in Sources */, DB4CA43A1B3A662A004B70F8 /* NSInvocation+BlocksKit.m in Sources */, @@ -1340,7 +1330,6 @@ DB4CA4451B3A662A004B70F8 /* NSMutableArray+BlocksKit.m in Sources */, DB4CA4D61B3A6657004B70F8 /* UIActionSheet+BlocksKit.m in Sources */, DB4CA4721B3A662A004B70F8 /* NSSet+BlocksKit.m in Sources */, - DB4CA5081B3A6657004B70F8 /* UIWebView+BlocksKit.m in Sources */, DB4CA42C1B3A662A004B70F8 /* NSArray+BlocksKit.m in Sources */, DB4CA4361B3A662A004B70F8 /* NSIndexSet+BlocksKit.m in Sources */, DB5C6C4C1C52005900778E5F /* NSNumber+BlocksKit.m in Sources */, diff --git a/BlocksKit/UIKit/UIWebView+BlocksKit.h b/BlocksKit/UIKit/UIWebView+BlocksKit.h deleted file mode 100644 index 779997fb9..000000000 --- a/BlocksKit/UIKit/UIWebView+BlocksKit.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// UIWebView+BlocksKit.h -// BlocksKit -// - -#import "BKDefines.h" -#import - -NS_ASSUME_NONNULL_BEGIN - -/** Block callbacks for UIWebView. - - @warning UIWebView is only available on a platform with UIKit. -*/ - -@interface UIWebView (BlocksKit) - -/** The block to be decide whether a URL will be loaded. - - @warning If the delegate implements webView:shouldStartLoadWithRequest:navigationType:, - the return values of both the delegate method and the block will be considered. -*/ -@property (nonatomic, copy, setter = bk_setShouldStartLoadBlock:, nullable) BOOL (^bk_shouldStartLoadBlock)(UIWebView *webView, NSURLRequest *request, UIWebViewNavigationType navigationType); - -/** The block that is fired when the web view starts loading. */ -@property (nonatomic, copy, setter = bk_setDidStartLoadBlock:, nullable) void (^bk_didStartLoadBlock)(UIWebView *webView); - -/** The block that is fired when the web view finishes loading. */ -@property (nonatomic, copy, setter = bk_setDidFinishLoadBlock:, nullable) void (^bk_didFinishLoadBlock)(UIWebView *webView); - -/** The block that is fired when the web view stops loading due to an error. */ -@property (nonatomic, copy, setter = bk_setDidFinishWithErrorBlock:, nullable) void (^bk_didFinishWithErrorBlock)(UIWebView *webView, NSError *error); - -@end - -NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/BlocksKit/UIKit/UIWebView+BlocksKit.m b/BlocksKit/UIKit/UIWebView+BlocksKit.m deleted file mode 100644 index ae4c659fd..000000000 --- a/BlocksKit/UIKit/UIWebView+BlocksKit.m +++ /dev/null @@ -1,80 +0,0 @@ -// -// UIWebView+BlocksKit.m -// BlocksKit -// - -#import "UIWebView+BlocksKit.h" -#import "A2DynamicDelegate.h" -#import "NSObject+A2DynamicDelegate.h" -#import "NSObject+A2BlockDelegate.h" - -#pragma mark Custom delegate - -@interface A2DynamicUIWebViewDelegate : A2DynamicDelegate -@end - -@implementation A2DynamicUIWebViewDelegate - -- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { - BOOL ret = YES; - - id realDelegate = self.realDelegate; - if (realDelegate && [realDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) - ret = [realDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; - - BOOL (^block)(UIWebView *, NSURLRequest *, UIWebViewNavigationType) = [self blockImplementationForMethod:_cmd]; - if (block) - ret &= block(webView, request, navigationType); - - return ret; -} - -- (void)webViewDidStartLoad:(UIWebView *)webView { - id realDelegate = self.realDelegate; - if (realDelegate && [realDelegate respondsToSelector:@selector(webViewDidStartLoad:)]) - [realDelegate webViewDidStartLoad:webView]; - - void (^block)(UIWebView *) = [self blockImplementationForMethod:_cmd]; - if (block) block(webView); -} - -- (void)webViewDidFinishLoad:(UIWebView *)webView { - id realDelegate = self.realDelegate; - if (realDelegate && [realDelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) - [realDelegate webViewDidFinishLoad:webView]; - - void (^block)(UIWebView *) = [self blockImplementationForMethod:_cmd]; - if (block) block(webView); -} - -- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { - id realDelegate = self.realDelegate; - if (realDelegate && [realDelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) - [realDelegate webView:webView didFailLoadWithError:error]; - - void (^block)(UIWebView *, NSError *) = [self blockImplementationForMethod:_cmd]; - if (block) block(webView, error); -} - -@end - -#pragma mark Category - -@implementation UIWebView (BlocksKit) - -@dynamic bk_shouldStartLoadBlock, bk_didStartLoadBlock, bk_didFinishLoadBlock, bk_didFinishWithErrorBlock; - -+ (void)load -{ - @autoreleasepool { - [self bk_registerDynamicDelegate]; - [self bk_linkDelegateMethods:@{ - @"bk_shouldStartLoadBlock": @"webView:shouldStartLoadWithRequest:navigationType:", - @"bk_didStartLoadBlock": @"webViewDidStartLoad:", - @"bk_didFinishLoadBlock": @"webViewDidFinishLoad:", - @"bk_didFinishWithErrorBlock": @"webView:didFailLoadWithError:" - }]; - } -} - -@end From 8d1570137005522e620e74ead88fcd6320e76fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=A4=A7=E5=AE=9D?= Date: Mon, 4 May 2020 18:38:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlocksKit/BlocksKit+UIKit.h | 1 - 1 file changed, 1 deletion(-) diff --git a/BlocksKit/BlocksKit+UIKit.h b/BlocksKit/BlocksKit+UIKit.h index 84625ae50..c60bdeefc 100644 --- a/BlocksKit/BlocksKit+UIKit.h +++ b/BlocksKit/BlocksKit+UIKit.h @@ -37,7 +37,6 @@ #import #import #import -#import #import #import #import