monotouch uiwebview无法找到本地HTML

前端之家收集整理的这篇文章主要介绍了monotouch uiwebview无法找到本地HTML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在Monotouch上构建一个iPhone应用程序.我项目的一部分使用本地网站内容.我将用于网站的所有html,js,css和图像复制到一个文件夹中,并将其导入我的monotouch项目.我已将所有这些文件的构建选项设置为Content.

我加载如下的本地Web内容

this.url = Path.Combine (NSBundle.MainBundle.BundlePath,“Content/index.html”);
webView.LoadRequest(new NSUrlRequest(new NSUrl(this.url,false)));

问题是当我运行项目时,它无法找到我的本地网站,当我尝试调试时,我收到了以下消息:

The requested URL was not found on this server.

/Users/*****/Library/Application Support/iPhone
Simulator/4.3/Applications/092E0D85-92F4-4F4E-9CD2-3FBBCD797F76/Project.app/Content/index.html

有趣的是,当我将链接复制到safari时,网页显示没有任何问题

我试图清理和重建项目几次,但没有任何变化.

谁能帮我这个?

我正在使用OS X Moutain Lion 10.8.2,MonoDevelop 3.0.5,Monotouch 6.0.6,xcode 4.5.2

提前致谢

解决方法

这很奇怪,对我来说效果很好.

试试这个:

var fileName = "Content/index.html";
webView.LoadHtmlString (File.ReadAllText (fileName),NSUrl.FromFilename (fileName));

猜你在找的HTML相关文章