爲什麼這個變量爲「無」即使我檢查是否self.photoImageView.image != nil
,在倒數第二行嘗試applyBlurEffect
時仍然出現fatal error: unexpectedly found nil while unwrapping an Optional value
錯誤。即使我有一個「if」語句來檢查它不是
你知道如何調和嗎?
if (output?.getAccel() == true){
if (output?.getImage() != nil){
if (self.photoImageView.image != nil){
println(photoImageView.image)
var blurredImage = self.applyBlurEffect(self.photoImageView.image!)
self.photoImageView.image = blurredImage
}
對於上下文,我有一個photoImageView
,並且當一個「加速度計按鈕」被插入該photoImageView
,這個函數使用圖像,模糊它,並且更新圖像作爲模糊的圖像。
此外,當我打印photoImageView.image
,它返回 Optional(<UIImage: 0x174087d50> size {1340, 1020} orientation 0 scale 1.000000)
。其中可能存在這個問題,但我需要一點幫助來解決它。
我不明白爲什麼這不起作用。我認爲這個問題與你在applyBlurEffect中做的事情有關,並不是因爲展開圖像給你零。 – rdelmar