我有一個ImageView。這是我使用的圖像添加到ImageView的以swogra編程式加載圖像
var imgstr = pf["ImageFileName"] as String
image = UIImage(named: imgstr)!
println(imgstr) //the output here is abc.png
self.Imageview.image = image
現在我有形象在我的項目文件夾,你可以在截圖
不過我得到在運行時此錯誤看到代碼
fatal error: unexpectedly found nil while unwrapping an Optional value
你可以檢查圖像'abc.png'列在__Build階段 - >複製捆綁資源_? –
可以self.ImageView爲零?你有沒有正確設置它?如果您使用的是Storyboard,是否正確設置了引用插口? – Nycen