Reputation: 4723
I am using a UIWebView
and loading an NSURL
there are 4 links in that page when I click a link this method is called. which is fine
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
}
after moving to next page my UINavigationBar
shows a back button
-(void)backButtonClicked
{
if ( myWebView.loading)
{
[myWebView goBack];
}
}
which takes me back to the main page, but if I again click the same link no delegate method is called. why is that? I need to get the current url every time I click a link.
Upvotes: 1
Views: 1595
Reputation: 8138
Try this in delegate...
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"Webview url: %@",webView.request.URL.absoluteString);
}
Upvotes: 1
Reputation: 147
You can try this :
NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:@"window.location"];
Upvotes: 2
Reputation: 1113
You have to store all the opened URLs in an array and when back button check if the tapped link is same as of stored link in array on last object then reload the web view.
Upvotes: 0