【发布时间】:2011-07-26 16:02:19
【问题描述】:
我有代码可以在 iOS 上完成这项工作。使用我在这里和网上找到的任何东西,我设法找到了制作 Cocoa Mac Os 版本的地方,但图像无法加载。 CSS 和 Javascript 似乎也没有加载。 HTML 的目录被添加到 Resources 组,但它被添加为文件夹引用(蓝色文件夹),这使得 Xcode 尊重 HTML 应用程序的目录结构。
这是我尝试使用的代码:
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"index"
ofType:@"html"
inDirectory:@"/Patient_eMMR_HTML5" ];
NSString *html = [NSString stringWithContentsOfFile:htmlPath
encoding:NSUTF8StringEncoding
error:nil];
[[webView mainFrame] loadHTMLString:html baseURL:[NSURL fileURLWithPath:
[NSString stringWithFormat:@"%@/Patient_eMMR_HTML5/",
[[NSBundle mainBundle] bundlePath]]]];
这是我基于上面使用的代码的 iOS 版本代码:
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"index"
ofType:@"html"
inDirectory:@"/Patient_eMMR_HTML5" ];
NSString *html = [NSString stringWithContentsOfFile:htmlPath
encoding:NSUTF8StringEncoding
error:nil];
[webView loadHTMLString:html
baseURL:[NSURL fileURLWithPath:
[NSString stringWithFormat:@"%@/Patient_eMMR_HTML5/",
[[NSBundle mainBundle] bundlePath]]]];
非常感谢任何帮助。谢谢。
【问题讨论】: