如何在swift 3中更改progressView的最大值

时间:2017-01-07 21:06:29

标签: swift3 uiprogressview

问题是进度视图有最大值1.0我试图改变它的文件大小,我从互联网上下载但我不能 请告诉我如何更改进度视图的最大值,以便与我下载的文件大小相匹配

以下代码:

let cell = tableView.dequeueReusableCell(withIdentifier: "DownloadCell", for: indexPath) as? DownloadCell

cell?.progreeView.progress = arrayOfObjects[indexPath.row].totalData

// totalData from object  is file size which i download it from the internet 

非常感谢

1 个答案:

答案 0 :(得分:2)

您不需要更改进度最大值,您只需要数学来计算progressView.progress。 例如,让我们说你的总数据是500,你当前下载的数据是328,然后是328/500 = 0.656,那就是你当前的进度,所以你可以这样做:(创建2个新变量)

let cell = tableView.dequeueReusableCell(withIdentifier: "DownloadCell", for: indexPath) as? DownloadCell

cell?.progreeView.progress = currentDownloadedData / totalSize