ios - How to detect when UIWebView starts loading when Webview is inside a Collection View cell? -
i loading collection view of cells containing uiwebview
s. there's time gap between when uicollectionview
's activity indicator stops spinning , uiwebview
loads. trying reference when loading starts (and when stops) in order add activity indicator ui. i'm not sure how here though since uiwebview
in collectionviewcell
, not collectionview
, in other words can't use delegate methods , set myself delegate in collectionview
s vdl? collectionviewcell
code:
import uikit import webkit class searchcollectionviewcell: uicollectionviewcell { @iboutlet weak var webview: uiwebview! @iboutlet weak var spinner: uiactivityindicatorview! func webviewdidstartload(_ webview: uiwebview) { print("we're loading") } }
you need implement uiwebviewdelegate
in cell , set cell delegate
in method webviewdidstartload
notified
import uikit import webkit class searchcollectionviewcell: uicollectionviewcell { @iboutlet weak var webview: uiwebview! @iboutlet weak var spinner: uiactivityindicatorview! override func awakefromnib() { super.awakefromnib() self.webview.delegate = self // initialization code } } extension searchcollectionviewcell : uiwebviewdelegate { public func webviewdidstartload(_ webview: uiwebview) { debugprint("start loading") } }
hope helps
Comments
Post a Comment