Swift uicollectionview中的uiwebview获得白色空白屏幕

Swift uicollectionview中的uiwebview获得白色空白屏幕,swift,webview,uicollectionview,Swift,Webview,Uicollectionview,我对uiwebview和collectionview有问题。在webview中加载本地html文件 webView.loadRequest(Request) 问题是在uiwebview中前后滚动多次会出现一个白色的空白屏幕。否则,它工作得很好。 使用下面的代码加载单元格 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionVi

我对uiwebview和collectionview有问题。在webview中加载本地html文件

webView.loadRequest(Request)
问题是在uiwebview中前后滚动多次会出现一个白色的空白屏幕。否则,它工作得很好。 使用下面的代码加载单元格

 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
 {         
     let cell = collectionView.dequeueReusableCell(withReuseIdentifier: STR_CollectionCell_IDENTIFIER, for: indexPath) as! HTMLCollectionViewCell

     let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])

     HTML_File_Name = Get_File_Name(Cellindex: indexPath.row)

     var FilePath = PATH_HTML_DE +  HTML_File_Name
     let url2 = URL(string: parameterString, relativeTo: textFileURL)!
     myRequest = URLRequest(url: url2)

     cell.LoadHTMLRequest(IN_Request: myRequest)

     return cell
}

最好使用缓存策略来反复加载web请求

let url = URL(string: "http://www.something.com")
let url_request = URLRequest(url: url!,
                  cachePolicy:NSURLRequest.CachePolicy.returnCacheDataElseLoad,
                  timeoutInterval: 10.0)

let webView = UIWebView()
webView.loadRequest(url_request)

CellForItemAtIndexPath?func collectionView(collectionView:UICollectionView,cellForItemAt indexPath:indexPath)->UICollectionViewCell{let cell=collectionView.dequeueReusableCell(带ReuseIdentifier:STR\u CollectionCell\u标识符,for:indexPath)as!HTMLCollectionViewCell您是否注册了该单元格?还可以使用其他信息编辑该问题。不要将其添加到注释中。请尊重您问题的读者,并在将来花时间格式化代码段。此外,Swift中的变量和函数名应以小写开头,而不是大写开头ing
Snake\u Case
。使用正确的命名可以让其他人更容易阅读。感谢您的评论。我以前没有任何经验,这就是原因。很抱歉。