@IBActionfunc stopButton(sender: UIButton){
//loading.stopAnimating()
let Alert =UIAlertController(title: "警告",message:"正在下载,确定要取消下载吗", preferredStyle:UIAlertControllerStyle.Alert)
let noCancel =UIAlertAction(title: "否", style: .Default) { (UIAlertAction) ->Void inprint("click no")
}
let yesCancel =UIAlertAction(title: "是", style: .Cancel, handler:alertView)
Alert.addAction(noCancel)
Alert.addAction(yesCancel)
self.presentViewController(Alert, animated:true, completion: nil)
}
func alertView(alert:UIAlertAction) {
loading.stopAnimating()
}
在点击停止按钮之后,会弹出警告框,询问是否停止下载,点击是,下载结束,点击否,继续下载.