0
我有一个小问题。我从火力地堡的图像,我尝试添加缓存,因为我用这种方式尝试,但像这样的,他们不会被缓存:从firebase和缓存加载图像swift3
我宣布这个变量
var uid:String = ""
var partitionUrl:String = ""
var titre:String = ""
而这个链接到火力点。
let storageRef = FIRStorage.storage().reference()
let databaseRef = FIRDatabase.database().reference().child("canticles")
该应用程序使用UID拿到冠军和图像,并显示在的UILabel和的UIImageView
@IBOutlet weak var titleCantique: UILabel!
@IBOutlet weak var partitionImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
getPartitionImage()
}
override func viewWillAppear(_ animated: Bool) {
print("partition uid : " + uid)
print("partition URL : " + partitionUrl)
print("partition TITLE : " + titre)
self.titleCantique.text = titre
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func getPartitionImage(){
DispatchQueue.main.async(execute: {
self.storageRef.child(self.partitionUrl).data(withMaxSize: 10*1024*1024, completion: { (data, error) in
if error != nil {
print(error!)
return
}
let image = UIImage(data: data!)
self.partitionImageView.image = image
})
})
}
}
问题是,当未连接手机,图片没有显示。 我可以通过为图像添加缓存来解决这个问题,然后它会显示在离线状态下?