ios webview載入本地網頁並解決亂碼問題

2021-06-17 15:57:34 字數 611 閱讀 5786

nsstring *htmlstring = [nsstring stringwithcontentsoffile:htmlpath];

[webview loadhtmlstring:htmlstring baseurl:nil];

如果需要用本地的話 baseurl 路徑設定為自己的resource

如果有亂碼問題;

//載入本地的html檔案

nsstring *resourcepath = [[nsbundle mainbundle] resourcepath];

//以utf8的編碼格式載入html內容

nsstring *htmlstring = [[nsstring alloc] initwithcontentsoffile:filepath encoding:nsutf8stringencoding error:nil];

= yes;

//將文字內容顯示到webview控制項上

[self.wbproblems loadhtmlstring: htmlstring baseurl: [nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]]];

iOS WKWebView載入本地網頁

property strong,nonatomic wkwebview webview property nonatomic,copy nsstring url 我這裡是將html資源檔案放置在工程內乙個bundle的資料夾內 拼接後的網頁路徑 self url self componentfile...

iOS webView 遠端h5優先載入本地資源

前言 uiwebview呼叫遠端h5頁面,優先載入本地 js css等資源,解決辦法就是對請求進行攔截。服務端 放在本文後面 客戶端需要對nsurlprotocol 的自定義類進行註冊,那麼所有的webview 對http請求都會被他攔截到 首先自定義nsurlprotocol類 import im...

本地網絡卡失而復得

我總結了一下具體恢復的步驟 1 以管理員許可權執行cmd,輸入指令 sfc scannow 進行掃瞄修復 檢查資源是否衝突 2 以管理員許可權執行cmd,輸入指令 regsvr32 netshell.dll regsvr32 netcfx.dll regsvr32 netman.dll 進行註冊與網...