I want to load html5 page, in my UIWebView in xcode, when I added files in my project for example: “for my html5:
I have css folder I have javascript file I have images, and my folder structure is like:
css/
javascript/
images/
when I adde these folders in xcode and I run the program, xcode can n’t get the address, it can load the html page but with out any picture, javascript and css since they are in the other folders, I know, when I put all file together not in separate folder everything works but I want to have real folder structure in my xcode (I don’t want to use group) would you please help me
for example
here it’s works
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"about.html" ofType:nil]];
but when I add about in one folder like
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"test/about.html" ofType:nil]];
the link it dosent work, How can I fixed this path problem in xcode
when I run about.html if all css,javascript and images are located in about folder everything works in xcode
but when I have them in separate folder about can not load the css / javascript and images
would you please give me some hints
Thanks in advance!
Edit ::
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"page1.html" ofType:nil]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
I want to use something like this folder : test/
[NSBundle mainBundle]pathForResource:@"test/page1.html" ofType:nil]];
You need to set the baseURL of your
UIWebViewinstance to be the URL of the directory in your main bundle with the content in it, and your links from your html need to be relative.The code below is a basic way, given my content is in the root of the main bundle.
You may need to get your baseURL differently, but that’s the idea.