Skip to content

Commit

Permalink
expose the request so it can be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
uzegonemad committed May 23, 2015
1 parent 09b72bd commit 39c26a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions TOWebViewController/TOWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
*/
@property (nonatomic,strong) NSURL *url;

/**
Get/set the request
*/
@property (nonatomic,strong) NSMutableURLRequest *urlRequest;

/**
The web view used to display the HTML content. You can access it through this
read-only property if you need to anything specific, such as having it execute arbitrary JS code.
Expand Down
14 changes: 10 additions & 4 deletions TOWebViewController/TOWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ - (void)setup

//Set the initial default style as full screen (But this can be easily overridden)
self.modalPresentationStyle = UIModalPresentationFullScreen;

//Set the URL request
self.urlRequest = [[NSMutableURLRequest alloc] init];
}

- (void)loadView
Expand Down Expand Up @@ -491,7 +494,10 @@ - (void)viewWillAppear:(BOOL)animated

//start loading the initial page
if (self.url && self.webView.request == nil)
[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
{
[self.urlRequest setURL:self.url];
[self.webView loadRequest:self.urlRequest];
}
}

- (void)viewWillDisappear:(BOOL)animated
Expand Down Expand Up @@ -596,7 +602,8 @@ - (void)setUrl:(NSURL *)url
if (self.webView.loading)
[self.webView stopLoading];

[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
[self.urlRequest setURL:self.url];
[self.webView loadRequest:self.urlRequest];
}

- (void)setLoadingBarTintColor:(UIColor *)loadingBarTintColor
Expand Down Expand Up @@ -803,8 +810,7 @@ - (void)reloadStopButtonTapped:(id)sender
//off our stored self.url property instead
if (self.webView.request.URL.absoluteString.length == 0 && self.url)
{
NSURLRequest *request = [NSURLRequest requestWithURL:self.url];
[self.webView loadRequest:request];
[self.webView loadRequest:self.urlRequest];
}
else {
[self.webView reload];
Expand Down

0 comments on commit 39c26a5

Please sign in to comment.