繁体   English   中英

加载Web视图并以编程方式拍摄快照以显示在collectionView中

[英]Load webviews and take snapshots programmatically to display in collectionView

我目前正在加载WebViewscollectionView ,可以,但是效果WebViews ,例如广告经常遮盖了webview的内容。 我想做的是以编程方式加载webview并对其进行快照,然后使用与WebViews本身相对的图像重新加载collectionView

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

        if let url = Urls?[indexPath.row] {
            self.activityIN.stopAnimating()
            self.progressLabel.removeFromSuperview()
            cell.webView.loadRequest(URLRequest(url: url))
        }


        return cell
    }
  • 创建2个单元格-一个具有webview的单元格,另一个具有imageview的单元格
  • 重新加载时,确定是否仍然存在屏幕截图,并显示带有imageview的单元格
  • 在Web视图中,使用自定义Web视图,该视图将在完成加载后保存快照,保存快照,将屏幕快照名称添加到Urls集合中,然后删除该Web视图并将其替换为imageview

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM