I am having one web view in which I am loading one HTML page. It is having document where each page is given link (like an index) at the start.
Requirement is : When click on web view contents URL, open that link in default safari application i.e. outside of an app.
My problem : When I click on content link it detects it as a hyperlink and open it in outside safari browser. If I double click on home button -> select my app -> click on same link again then it is showing me content in the app browser i.e. scrolling down to that content. I am using shouldStartLoadWithRequest delegate method but it does not get call in second scenario.
My Question : How can I achieve both. If some URL gets clicked then open it in outside app. In above case it should just scroll down to show page contents.
Sample code below:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
switch (navigationType) {
case UIWebViewNavigationTypeFormSubmitted:
// request was caused by an image that's being loaded
break;
case UIWebViewNavigationTypeBackForward:
// request was caused by an image that's being loaded
break;
case UIWebViewNavigationTypeReload:
// request was caused by an image that's being loaded
break;
case UIWebViewNavigationTypeFormResubmitted:
// request was caused by an image that's being loaded
break;
case UIWebViewNavigationTypeLinkClicked: {
// user clicked on link
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
case UIWebViewNavigationTypeOther:
// request was caused by an image that's being loaded
break;
}
return YES;
}
Any help ?