【发布时间】:2016-04-21 09:38:16
【问题描述】:
我目前正在开发 Swift iPhone 应用中的上传功能。
在上传过程中,我想显示一个进度指示器。但是,任何需要刷新显示的代码命令似乎都不会在几秒钟之前执行。
例如使用下面的代码,当数据开始发送时,PROGRESS 会立即出现在控制台中,但顶视图会在大约 10 秒后消失。
func URLSession(_ session: NSURLSession,
task task: NSURLSessionTask,
didSendBodyData bytesSent: Int64,
totalBytesSent totalBytesSent: Int64,
totalBytesExpectedToSend totalBytesExpectedToSend: Int64) {
//uploadProgressCallback(uploadProgressRatio: min(Double(totalBytesSent) / self.uploadedFileTotalSize, 1.0) )
print("PROGRESS")
let topController:UINavigationController = UIApplication.sharedApplication().keyWindow!.rootViewController as! UINavigationController
topController.view.alpha = 0.0
}
知道为什么吗?
非常感谢您的帮助。
拉斐尔
【问题讨论】: