iOS 學習之WebView的使用

2021-07-03 16:13:48 字數 919 閱讀 6499

viewcontroller.m
- (void)viewdidload  

手機的網路環境是實時變化的,網路慢的時候,怎麼提示使用者網頁正在開啟呢?在網頁開啟出錯的時候怎麼提示使用者呢?這時候我們就需要知道網頁什麼時候開啟的,

什麼時候載入完成,什麼時候出錯了。那麼我們需要實現這個協議

uiwebview中幾個重要的函式

1.- (void )webviewdidstartload:(uiwebview  *)webview   網頁開始載入的時候呼叫

2.- (void )webviewdidfinishload:(uiwebview  *)webview  網頁載入完成的時候呼叫

3.- (void)webview:(uiwebview *)webview  didfailloadwitherror:(nserror *)error 網頁載入錯誤的時候呼叫

載入等待介面

為了給使用者更直觀的介面效果,我們加上等待的loading介面試試

在webviewdidstartload加入等待

[cpp] view plaincopy- (void) webviewdidstartload:(uiwebview *)webview

- (void) webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error

{ [activityindicator stopanimating];

uiview *view = (uiview*)[self.view viewwithtag:108];

[view removefromsuperview];

iOS與Android中webview的css適配

1.js執行效率及記憶體洩漏問題 問題比較大,需要逐步探索優化 2.css適配問題 這裡主要記錄下自己實踐過的css適配問題,以備以後調研及開發使用 css適配 1.螢幕畫素值適配 不常用,需要配合密度來適配 這種情況可在請求頁面時代入引數,解析度及密度值,由伺服器端決定吐不同css,可以解決全部適...

IOS之SVN客戶端versions的使用

多人協作開發專案。每個只是修改自己的模組,修改過後同步修改的內容,每個階段 都有版本,使用版本控制工具,比如cvs古老,svn簡單專案常用,mkdir repository svnserve.conf general anon access read auth access write passwo...

ios開發,NSFileManager的使用

在網上我們可以看到很多介紹nsfilemanager的文章,接下來我們引用 這篇部落格中的知識,學習nsfilemanager的基本功能。nsstring getdocumentspath 建立資料夾 void createdirectory else 建立檔案 void createfile el...