[英]PFFile to PFImageView
我在iOS應用程序中無法顯示從Parse拍攝的圖像。 我決定使用PFImageView。 這是我到目前為止的內容:
我聲明了PFImageView圖片:
@IBOutlet var pic: PFImageView!
在查詢中:
self.name.text = object["Name"] as String
var imagefile = object["image"] as PFFile
self.pic.file = imagefile
self.pic.loadInBackground()
self.desc.text = object["Description"] as String
確實很奇怪,因為其他的都在工作(名稱和描述),並且我確信數據庫中有一個名為“ image”的字段(是的,我小的)。 我總是收到此錯誤:致命錯誤:解開Optional值時意外發現nil。
有什么見解嗎?
檢查文件是否為nil
if object.objectForKey("image") != nil
{
var imagefile = object["image"] as PFFile
self.pic.file = imagefile
self.pic.loadInBackground()
}
嘗試這個
if let imagefile = object["image"] as PFFile {
self.pic.file = imagefile
self.pic.loadInBackground()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.