How to load NSURL which contains hash fragment “#” with UIWebView?

前端 未结 4 1853
刺人心
刺人心 2021-01-11 20:16

Given a local URL address like index.html

Now I need to use UIWebView to load it in iPad. I followed these steps:

  1. Create NSURL

    <
4条回答
  •  自闭症患者
    2021-01-11 21:06

    for reference in swift:

    let path = NSBundle.mainBundle().pathForResource("index", ofType: "html", inDirectory: "web")
    var url = NSURL(fileURLWithPath: path!)
    url = NSURL(string: "#URL_FRAGMENT", relativeToURL: url!)
    let request = NSURLRequest(URL: url!)
    self.webView.loadRequest(request)
    

提交回复
热议问题