我需要一些帮助。
我使用像tihs
这样的sd_setImageWithURL self.downloadButton.addTarget(self, action: #selector(self.stopDownloading), forControlEvents: .TouchUpInside)
self.imageView.sd_setImageWithURL(NSURL(string:myURL!)!, placeholderImage: UIImage(named: "placeHolderImage"), options: SDWebImageOptions.ProgressiveDownload , progress: {
(receivedSize: Int!, expectedSize: Int!) in
if(receivedSize > 0 )
{
self.percentString = String(format: "%.0f",(Float(receivedSize) / Float(expectedSize) * 100))
[self.downloadProgress.setProgress(Float(receivedSize) / Float(expectedSize), animated: true)]
self.downloadStateLabel.text = "\(receivedSize/1000000) / \(expectedSize/1000000)MB (\(self.percentString)%)"
NSLog("%@", self.percentString)
}
}, completed: {
(image, error, cacheType, url) in
NSLog("Completed'");
})
func stopDownloading(sender: AnyObject)
{
NSLog("stopDownloading Clicked")
self.imageView.sd_cancelCurrentImageLoad()
}
当我单击Button时,我可以在stopDownloading函数中获取Log“stopDownloading Clicked”,但sd_cancelCurrentImageLoad()不起作用。
继续下载,我可以获得完成日志。
如何停止下载或取消正在进行的sd_setImageWithURL?
THX。