更新时间:2023-02-06 15:08:08
你需要在你的单元格中实现 UIWebViewDelegate
并将你的单元格设置为 delegate
然后在方法 webViewDidStartLoad
你会收到通知
You need to implement UIWebViewDelegate
in your cell and set you cell as delegate
then in the method webViewDidStartLoad
you will be 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")
}
}
希望能帮到你