ios - 动画完成时隐藏 UIProgressView

标签 ios swift animation cloudkit uiprogressview

我正在使用 CKOperation 将记录数组保存在云套件中,如下所示并使用进度 View 显示进度。

    let saveOperation = CKModifyRecordsOperation(recordsToSave: ckRecord, recordIDsToDelete: nil)

    saveOperation.perRecordProgressBlock = {
        record, progress in
        if progress >= 1 {
            self.completedRecord.addObject(record)
            let totalSavedRecord = Double(self.completedRecord.count)
            let totalProgress = totalSavedRecord / self.totalStudent
            let percentageProgress = Float(totalProgress * 100)
            progressView.setProgress(percentageProgress, animated: true)

            println(progress)
            println(progressView.progress)
            println(percentageProgress)

        }
    }

我想在进度 View 达到 100% 且动画完成时隐藏进度 View 。

目前,我很快就达到了百分比进度 100.0,但进度 View 动画发生时有一些延迟。如果我在百分比进度达到 100.0 时隐藏,那么我将永远不会看到任何动画。

进度值始终为 1.0。

progressView.progress 的值始终为 1.0。

我想再次显示从 0% 到 100% 的完整动画,然后隐藏进度 View 。

最佳答案

CloudKit 回调 block 在后台线程上执行。当您更新 UI 时,您应该在主线程上执行此操作。否则你可能会看到像这样奇怪的延迟。尝试将代码包装在如下所示的 block 中:

NSOperationQueue.mainQueue().addOperationWithBlock {
   progressView.setProgress(percentageProgress, animated: true)
}

关于ios - 动画完成时隐藏 UIProgressView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30766311/

相关文章:

ios - 有谁知道_UIApplicationDidRemoveDeactivationReasonNotification?

ios - 核心数据 - 为什么获取请求返回零?

swift - 无法出示 Apple Pay 授权 Controller

jquery - CSS3 动画填充模式 : forwards

ios - 获取 UITableViewCell 中的 Button 以使用所有可用空间

iOS 13 - 如何登录内购沙盒账户?

ios - 条形图(创建为 CALayer)高度/边界动画

ios - 如何在快速单击按钮时从 Storyboard 中调用 xib 文件

css - 在CSS中为对 Angular 线设置动画

jquery - 停止动画后更改 css 属性