我想使用LoadFileUrl方法加載WKWebView中的本地html文件,但是我得到的只是一個空白視圖。這是一個Xamarin.Mac應用程序(尚未沙盒)。WKWebView使用LoadFileUrl加載本地內容
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」
感謝您的幫助!
http://stackoverflow.com/questions/24882834/wkwebview-not-loading-local-files-under-ios-8 – Gusman
@Gusman感謝,但我已經看到了鏈接,如果我沒有弄錯,「LoadFileUrl」應該是解決方案,但它不起作用! 它在ElCapitan上可能還有錯誤嗎?我應該將html文件複製到「temp」文件夾中並從那裏加載它? – frenchfaso
它應該加載,更好地看到webview檢查器,並查看加載時是否有任何錯誤:http://stackoverflow.com/questions/25200116/how-to-show-the-inspector-within-your-wkwebview-based-桌面應用程序 – Gusman