I have a UIWebView where relative links fail to load properly, because the view was loaded from a data object after the html data has been locally manipulated, not direct from a URL. Now all the relative links on the page fail, because the UIWebView doesn’t know what they’re relative to.
For example:
<IMG SRC="img/foo.jpg">
wouldn’t load because rather than looking to
http://theoriginalsite.com/img/foo.jpg
for the file, the UIWebView looks in
iphonefilesystem/thisapp/tempdir/img/foo.jpg
Is there a way to reset the UIWebView’s base URL, so that these links will work? Am I stuck with adding another pass to the html data manipulation to rewrite all the relative URLs within?
That’s exactly what the baseURL parameter in the following UIWebView methods is for:
Have a look at the documentation here.