Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:07:17+00:00 2026-06-12T17:07:17+00:00

I want to load html5 page, in my UIWebView in xcode, when I added

  • 0

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]];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:07:18+00:00Added an answer on June 12, 2026 at 5:07 pm

    You need to set the baseURL of your UIWebView instance 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.

    //find my html file
    NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"htmlfile-to-load" ofType:@"html"];
    //load it into an NSData
    NSData *htmlData = [NSData dataWithContentsOfFile:htmlFilePath];
    //get the URL of the bundles resource directory
    NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath] isDirectory:YES];
    //load tableView
    [self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
    

    You may need to get your baseURL differently, but that’s the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with UIWebView project and I want to load an HTML file
I have a JSON file which contains HTML content. I want to load it
i have a uitableview which will load a uiwebview with a long page (static
I have a UIWebView class that is added to each storyboard on load, but
I want to load picture from web server without refreshing the page. I have
i'm creating an app in which i have a uiwebview. I want to load
I want to load a html page from a file, and append a hash
I have created a dialog box and i want to load a HTML page
i have a upload script that works with html5 file api and i want
I want to load a local jqmobile html file into a webview. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.