【发布时间】:2016-03-01 14:44:52
【问题描述】:
我正在尝试使用 LoadFileUrl 方法在 WKWebView 中加载本地 html 文件,但我得到的只是一个空白视图。这是一个 Xamarin.Mac 应用(还没有沙盒)。
WKWebViewConfiguration conf = new WKWebViewConfiguration();
WKWebView www = new WKWebView (View.Frame, conf);
View = www;
string index = Path.Combine (NSBundle.MainBundle.BundlePath, "WebApp/Index.html");
string webAppFolder = Path.Combine (NSBundle.MainBundle.BundlePath, "WebApp");
www.LoadFileUrl (new NSUrl ("file://"+index), new NSUrl ("file://"+webAppFolder));
使用“LoadRequest”从远程服务器加载网页效果很好。
“Index.html”文件的构建操作是“BundleResource”
感谢您的帮助!
【问题讨论】:
-
@Gusman 谢谢,但我已经看到了链接,如果我没看错的话,“LoadFileUrl”应该是解决方案,但它不起作用! ElCapitan 上是否仍然存在问题?我应该将 html 文件复制到“temp”文件夹中并从那里加载吗?
-
应该可以加载了,最好看看webview inspector,看看加载时有没有报错:stackoverflow.com/questions/25200116/…
标签: c# xamarin wkwebview xamarin.mac