Monday, December 16, 2013

UIWebView how to load a local HTML?

The Internet to find some code that did not load after running successfully.

There are a good way?

Reply:
NSBundle * bundle = [NSBundle mainBundle];
NSString * resPath = [bundle resourcePath];
NSString * filePath = [resPath stringByAppendingPathComponent: @ "Home.html"];

webView loadHTMLString: [NSString stringWithContentsOfFile: filePath]
baseURL: [NSURL fileURLWithPath: [bundle bundlePath]]];

This way you can display at a local HTML, just found incomplete display pictures did not show up, because it is unclear ...
Reply:
The path should be the relationship
Look at the pictures in the path html
Reply:
html path picture is Home_files / ...
Home_files is loaded picture folder name, I put this folder and Home.html has been placed under the same path together and added to the project resource.
Or no effect
Reply:
Resources xcode project is it?
But I do not remember the package into the target directory will be put under the same right?
But I really did not set off to open a file in the target folder
Perhaps a look in this direction
Reply:
The problem of the path. Way before loading may be a problem, reload it again after it.
Reply:
In html if there is a hyperlink or how to link the current PP

No comments:

Post a Comment