Reputation: 249
I am getting a data from url . I am showing in a Web-view Everything fine,but my requirement is i want to add references functionality like it wikipedia as shown in image . In Wikipedia when click that tag it scroll down to that position but now my requirement is when user click on that reference i want to show popup . Is It possible?
Thanks in advance.
Upvotes: 3
Views: 1434
Reputation: 2589
You can make use of UIWebViewDelegate method
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
This will be called before the web view begins loading.
Here argument UIWebViewNavigationType
is an enum, which holds the value of the navigation type, check whether the navigationType is UIWebViewNavigationTypeLinkClicked
. If Yes that means webView is loading page because of any of the link is clicked.
Code will look something like this
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if (navigationType == UIWebViewNavigationTypeLinkClicked)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"url" message:[[request URL] absoluteString] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
return YES;
}
Hope this helps you.
Upvotes: 2