Reputation: 37
I have a UIWebView
and I have multiple Links within my webpage from which I want to open the links depending on which links are clicked, I want to perform different actions on different links, point is how I can identify different links? I am using
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
//link clicked... but which one?
}
Upvotes: 0
Views: 193
Reputation: 12671
You need to find out which url is clicked by using the request.URL
and check what is the link you are clicking by using rangeOfString
method as I show under
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
if ([[request.URL absoluteString] rangeOfString:@"http://firstLink"].location!=NSNotFound){
//perform your action..
} else if ([[request.URL absoluteString]rangeOfString:@"http://secondLink"].location!=NSNotFound){
/// perform action for second link..
}
}
Upvotes: 2