-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
huangyibiao
authored and
huangyibiao
committed
Jan 13, 2016
1 parent
df83dce
commit 79a1317
Showing
14 changed files
with
144 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-275 Bytes
(99%)
RuntimeDemo.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// UIWebView+Swizzling.h | ||
// RuntimeDemo | ||
// | ||
// Created by huangyibiao on 16/1/13. | ||
// Copyright © 2016年 huangyibiao. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIViewController (Swizzling)<UIWebViewDelegate> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// UIWebView+Swizzling.m | ||
// RuntimeDemo | ||
// | ||
// Created by huangyibiao on 16/1/13. | ||
// Copyright © 2016年 huangyibiao. All rights reserved. | ||
// | ||
|
||
#import "UIViewController+Swizzling.h" | ||
#import "NSObject+Swizzling.h" | ||
|
||
@implementation UIViewController (Swizzling) | ||
|
||
+ (void)load { | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
[self swizzleSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:) | ||
withSwizzledSelector:@selector(hdf_webView:shouldStartLoadWithRequest:navigationType:)]; | ||
}); | ||
} | ||
|
||
- (BOOL)hdf_webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | ||
NSString *url = request.URL.absoluteString; | ||
|
||
// 注意containsString是iOS8以后才有,具体要兼容ios6则需要自己写 | ||
// 这里只是为了简便测试 | ||
if ([url containsString:@"userId"] && [url containsString:@"token"]) { | ||
return [self hdf_webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; | ||
} | ||
|
||
if ([url isEqualToString:@"about:blank"]) { | ||
return [self hdf_webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; | ||
} | ||
|
||
url = [NSString stringWithFormat:@"%@?userId=123&token=ssdfsfdf", url]; | ||
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; | ||
[webView loadRequest:req]; | ||
|
||
return NO; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters