IOS load local HTML page JS CSS images and other files

Source: Internet
Author: User

Development environment: XOCDE Version 7.0.1 (7a1001)

Simulator Sdk:version 9.0 (SimulatorApp-620 CoreSimulator-179)

Project requirements: When entering a new page, WebView presents the local HTML page with JS interaction.

Need to note: The afternoon did not jump out, the wrong reason is to drag the project to display the HTML and other resources, choose the wrong option.

With creat groups selected, the runtime crashes:

Reason: ' * * *-[nsurl Initfileurlwithpath:]: nil string parameter '

Code section:

UIWebView *tmpwebview = [[uiwebview alloc] initwithframe:self. View. Bounds];

    [tmpwebview loadrequest:[nsurlrequest requestwithurl< Span class= "S1" >:[nsurl fileurlwithpath:[[< span class= "s2" >nsbundle mainbundle] Pathforresource:@ "demo" oftype :@ "html" indirectory:@ "chart" ]]];

[self. View addsubview: Tmpwebview];

The meaning of the three parameters:

1, Pathforresource:@ "Demo": Demo is the local HTML file name

2, OfType:@ "html": Don't say more. File Type

3. Indirectory:@ "Chart": The name of the folder you dragged into the project.

Run so that it can be loaded!

IOS load local HTML page JS CSS images and other files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.