进度视图不更新

时间:2017-01-23 03:17:19

标签: ios swift progress-bar

我试图从进度块(解析)中获取一个返回完成%的进度视图。

当我打印百分比时,我得到:

16.0
17.0
18.0
ect

所以它正在返回,当我打印progressBar.progress时,我得到:

0.0
all the way to 
1.0

但进度条仍然没有更新:

}, progressBlock: { (percent) in
   // print(Float(percent))
    DispatchQueue.main.async {
        cell.progressBar.setProgress(Float(percent/100), animated: true)
            //print(cell.progressBar.progress)
    }

//cell.progessBar.progress = Float(percent)

if percent == 100 {
    cell.progressBar.isHidden = true
}

})

请注意,单元格是定义的自定义单元格:

func didDoubleTap(gesture: UITapGestureRecognizer) {

    let point: CGPoint = gesture.location(in: self.collectionView)

    if let selectedIndexPath: IndexPath = self.collectionView.indexPathForItem(at: point) {
        // let selectedCell: UICollectionViewCell = self.collectionView.cellForItem(at: selectedIndexPath as IndexPath)!
        // let indexItem = selectedIndexPath[1]
        // create instance of the cell so we can manipulate the images
        let cell: JourneyCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: selectedIndexPath) as! JourneyCollectionViewCell

1 个答案:

答案 0 :(得分:1)

你正朝着正确的方向前进。细胞定义的问题。

使用在没有垃圾的情况下创建的索引允许编辑单元格。

let cell: JourneyCollectionViewCell = self.collectionView.cellForItem(at: selectedIndexPath ) as! JourneyCollectionViewCell