Given a local URL address like index.html
Now I need to use UIWebView
to load it in iPad. I followed these steps:
-
Create NSURL
NSURL *url = [NSURL fileURLWithPath:@"http://mysite.com#page1"];
-
Load with UIWebView for local HTML/JS/CSS etc
[webView loadRequest:[NSURLRequest requestWithURL:url]];
But it doesn't work, because "#" is converted to "%23", so the URL string is
http://mysite.com%23page1
My question is, how to fix this auto-conversion issue and let UIWebView
access the URL which contains the hash fragment "#"?
Best Answer
User URLWithString to append fragment to your url, like this:
Hope it will help :)
EDIT: Swift 3 version: