Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dusker

macrumors member
Original poster
May 31, 2009
41
0
Hi Everyone,
i have a following problem:
i'd like to build a simple offline webpage browser, the webpage is pure HTM files. The structure looks like this:

index.htm
/subpages/page1.htm
/subpages/page2.htm

Ofcourse there're a lot of subpages not just two, and here's my question. I'm able to load the index htm into UIWebView using loadrequest, but index.htm contains links to subpages in a form of <a href="subpages/page1.htm">page1</a> and those links won't work. Can anyone help out?

thanks for help in advance
peter
 
Hi Everyone,
i have a following problem:
i'd like to build a simple offline webpage browser, the webpage is pure HTM files. The structure looks like this:

index.htm
/subpages/page1.htm
/subpages/page2.htm

Ofcourse there're a lot of subpages not just two, and here's my question. I'm able to load the index htm into UIWebView using loadrequest, but index.htm contains links to subpages in a form of <a href="subpages/page1.htm">page1</a> and those links won't work. Can anyone help out?

thanks for help in advance
peter

Look at the UIWebViewDelegate's shouldLoadRequest method. When they click on the link this gets called and you load the new htm file into it yourself.
 
I think you need to specify the baseURL in one of the methods that takes that parameter to load your index.htm file.
 
Look at the UIWebViewDelegate's shouldLoadRequest method. When they click on the link this gets called and you load the new htm file into it yourself.

what do you mean yourself? if the two htm files are in rood directory of a bundle hyperlinks work perfectly. issues are when the folders get involved.

Did you create that directory structure wherever you put your files? (bundle or sandbox Documents directory)?
i just dragged and dropped the folder into resources in xcode

I think you need to specify the baseURL in one of the methods that takes that parameter to load your index.htm file.
how to specify baseUrl in loadrequest method?
 
Would you mind providing me with one hint, meaningly what other method would allow me to load html file into uiwebview?

Um, loadHTMLString:baseURL: and loadData:MIMEType:textEncodingName:baseURL:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.