I'm writing an iOS app which will load a KRPano panorama inside a UIWebView offline. This means I have copied my KRPano file structure (index.html + data directory) inside my iOS Project and I'm trying to load the file using the swift code:
//load a file
guard let urlResource = NSBundle.mainBundle().URLForResource("index", withExtension: "html") else {
print ("error")
return
}
let webRequest = NSURLRequest(URL: urlResource)
webView.loadRequest(webRequest)
which btw works if the panorama is loaded from a remote location. What could be the problem?
It is impossible without manual editing of Krpano files. We solved this problem in our app (Offline Pages Pro) by automatically fixing up JavaScript documents as they are downloaded from network. Our implementation is quite complicated, but in the end it allows browsing Krpano tours offline.
The problem is that Krpano HTML5 viewer uses XMLHttpRequests to load content. If the content is local (i.e. file:// ) XMLHttpRequest can succeed too but it will not produce HTTP status code 200 which Krpano expects.
You can try implementing NSURLProtocol to override XMLHttpRequests and it MAY work in IOS 9 but as of iOS 8, it didn't work because XMLHttpRequests bypassed NSURLCache and NSURLProtocol altogether.