Search code examples
htmliosswiftuiwebview

IOS Swift - UIWebView jump to anchor tag


I am loading a local html file and would like to jump to an anchor tag somewhere on the page. I am using this code to load the file:

        let documentDirectoryURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let fileDestinationUrl = documentDirectoryURL.appendingPathComponent("page.html")
        let request = URLRequest(url: fileDestinationUrl)
        webView.loadRequest(request)

Is there away to jump to an anchor tag on this page


Solution

  • I have just confirmed that they could work also in iPhone6, after updating its OS to iOS 10.3, the same version of the simulator.