Reputation: 365
I will have to create an offline app from a received html5 file (sort of just display it in a UIWebView, I have no idea wether it will be multiple pages or just one). I have a very limited knowledge about html programming and such, and unfortunately due to a limited time frame I can't spend much time reading up about it. Are there any limitations to trying to display this offline in a webview or maybe other 'catches' that I need to be aware of?
Thank you in advance.
Upvotes: 3
Views: 7267
Reputation: 3685
If you are not changing the contents of the webpage, you can embed the HTML and all files and you won't have to worry about HTML5 since it's all already included
So create the HTML file and keep it in a folder (let's call it "index.html" and the folder "code" for this example) and drag it into your Supporting Files folder in xcode. Click the "Copy items..." checkbox and "create folder references..."
Then use this code in your ViewDidLoad:
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"index"
ofType:@"html"
inDirectory:@"code"];
NSURL* fileURL = [NSURL fileURLWithPath:filePath];
NSURLRequest* request = [NSURLRequest requestWithURL:fileURL];
[webView loadRequest:request];
IF YOU WANT TO PULL A FILE OFF THE WEB: to begin the HTML5 file, start it with
<!DOCTYPE HTML>
(seriously, that's all that's needed for "html5")
Then to make it so you can view the files offline, create a "manifest" file, so next add the line
<html manifest="example.manifest">
Then in a text editor list all the items to be included for offline (index.html, logo.jpg, page2.html, logo2.jpg, etc) boom, done
These 2 links are good resources for offline content [http://ofps.oreilly.com/titles/9781449383268/chapOfflineApplicationCache.html][1] http://www.html5rocks.com/en/tutorials/appcache/beginner/
[1]: http://ofps.oreilly.com/titles/9781449383268/chapOfflineApplicationCache.html [removed from web]
Upvotes: 9