滚动到左/右快速时进度视图丢失

时间:2016-08-26 08:16:09

标签: swift uicollectionview uiprogressview

我有水平位置的集合视图。用户可以下载文件,显示进度视图,下载完成后进度视图完全填充蓝色但如果我滚动集合视图,直到已经下载的文件不可见,进度视图丢失

这是我的代码

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationController?.navigationBarHidden = true
}
 override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(true)
    self.navigationController?.navigationBarHidden = true
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    let cell: magazineCell = self.collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! magazineCell

    cell.progressDownload.hidden = true //the progress bar
    cell.progressLabel.hidden = true //download percent
    cell.progressDownload.setProgress(0, animated: true)
}

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    cell.progressDownload.hidden = false
    cell.progressLabel.hidden = false
}

1 个答案:

答案 0 :(得分:1)

当重新创建滚动单元格再次隐藏进度条时,您需要设法检查是否已经下载,然后设置进度条显示/隐藏和下载进度。