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