Skip to content

Instantly share code, notes, and snippets.

@fahied
Created August 26, 2014 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fahied/08999c28a86a62dea5d7 to your computer and use it in GitHub Desktop.
Save fahied/08999c28a86a62dea5d7 to your computer and use it in GitHub Desktop.
jquery hash or query in UIWebview
// set path for the file to load in uiwebview
NSString *filePath = [resourceDir stringByAppendingPathComponent:@"index.html"];
// convert to NSURL object, remember not to incoude #tag yet, as fileURLWithPath will replacce jquery # with %23
// and will cause trouble to load your page properly
NSURL *fileURL = [NSURL fileURLWithPath:menuPath];
// add hash here
fileURL = [NSURL URLWithString:@"#menu" relativeToURL:fileURL];
// in case of query
menuURL = [NSURL URLWithString:@"?query" relativeToURL:menuURL];
//load webview
[self.webView loadRequest:[NSURLRequest requestWithURL:menuURL]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment