Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shouldStartLoadWithRequest appending link with applewebdata

I am receiving a description text in HTML format, and I am loading it in a webview, if a link clicked in the description so I load it in separate view controller. But shouldStartLoadWithRequest giving a some appended link. here is my code

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked) {

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    WebsiteViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WebsiteViewController"];
    vc.url = request.URL.absoluteString;
    NSLog(@"link is : %@", [[request URL] absoluteString]);
    [self.navigationController pushViewController:vc animated:YES];
    return false;
}
return true;
}

it prints this

link is : applewebdata://038EEEBF-A4C9-4C7D-8FB5-32056714B855/www.yahoo.com

and I am loading it like this

[webViewDescription loadHTMLString:description baseURL:nil];
like image 547
Raheel Sadiq Avatar asked Nov 27 '22 17:11

Raheel Sadiq


1 Answers

As you are using loadHTMLString and you are setting baseURL to nil therefore applewebdata URI scheme is used by iOS instead of the “http” in URIs used for accessing internal resources on the device. You could try setting the baseURL

like image 79
nsgulliver Avatar answered Dec 05 '22 15:12

nsgulliver