2017-03-04 68 views
-1

enter image description here我正在拍攝來自url的圖像我的應用程序崩潰在if let pngImageData = UIImageJPEGRepresentation(img!, 0.25)。僅適用於iOS 10.2.1的iPad Air 2。完美適用於iPad 3rd的iOS 9.3.5,iPad 2的iOS 9.3.5,iPhone 6的iOS 10.2.1以及iPhone 5s的iOS 10.2.1。應用程序正在崩潰`如果讓pngImageData = UIImageJPEGRepresentation(img !, 0.25)

+0

顯示崩潰報告 –

+0

刪除**從IMG – 2017-03-04 09:01:11

+0

可能的複製![什麼是「致命的錯誤:意外發現零而展開的可選值」?意思是( http://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found-nil-while-unwrapping-an-optional-valu) – Hamish

回答

1

從您提供的信息,唯一可能導致此崩潰的是img屬性等於零。 請試試這個:

if let img = img, let pngImageData = UIImageJPEGRepresentation(img, 0.25) { ... }