Skip to content

Commit 8868dfb

Browse files
committed
Merge pull request TimOliver#29 from VladimirGoncharov/master
Added an optional request checking handler block.
2 parents 4a41ec0 + a23c6ae commit 8868dfb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

TOWebViewController/TOWebViewController.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
*/
127127
@property (nonatomic,copy) void (^modalCompletionHandler)(void);
128128

129+
/**
130+
Managing queries and navigation
131+
*/
132+
@property (nonatomic,copy) BOOL (^shouldStartLoadRequestHandler)(NSURLRequest *request, UIWebViewNavigationType navigationType);
133+
129134
/**
130135
On iOS 6 or below, this can be used to override the default fill color of the navigation button icons.
131136

TOWebViewController/TOWebViewController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,15 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
692692
{
693693
BOOL shouldStart = YES;
694694

695+
if (self.shouldStartLoadRequestHandler)
696+
{
697+
shouldStart = self.shouldStartLoadRequestHandler(request, navigationType);
698+
}
699+
695700
//TODO: Implement TOModalWebViewController Delegate callback
696701

697702
//if the URL is the load completed notification from JavaScript
698-
if ([request.URL.absoluteString isEqualToString:kCompleteRPCURL])
703+
if ([request.URL.absoluteString isEqualToString:kCompleteRPCURL] || !shouldStart)
699704
{
700705
[self finishLoadProgress];
701706
return NO;

0 commit comments

Comments
 (0)