Home  >  Article  >  Web Front-end  >  iOS加载本地HTML注意点_html/css_WEB-ITnose

iOS加载本地HTML注意点_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:14:541287browse

今天在做本地html的时候遇到了一些小问题 写下来分享给大家


1.关于导入文件

3C80CFC2-6E8E-497B-9D7A-E4FB298618A8.png

因为前段JS CSS 的调用有严格的页面结构 所以我们导入文件的时候尽量选择下面这种情况!当然如果前段代码跳转以及引用js css 并没有文件结构 选择第一种

2.关于加载html

当我们选择第二种方式导入文件后 ,之前的[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]]就不能找到html 的Index页了.应该用[[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:@"html"];其中subdirectory就该写你index页的目录 如果有多层目录结构应写html/xxx还有一种方法就是直接拼接目录[[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/html/index.html"]


大家都是新手 多分享 多学习

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn