0

我有一个数组,UIImages我正在使用UIImagePNGRepresentation. 这些是从我的照片库UIImages中加载的。PHAssets大多数转换都没有问题,除了少数会导致它与消息一起崩溃:

fatal error: unexpectedly found nil while unwrapping an Optional value

将 打印UIImages到控制台揭示了不会导致崩溃的那些和那些会导致崩溃的区别:

result #0: <UIImage: 0x13a46c5b0>, {60, 45}  // this works
thumbnail #0 finished loading from lib
result #1: <UIImage: 0x13b133b00>, {60, 45}  // this too
thumbnail #1 finished loading from lib
result #2: <UIImage: 0x13a46d440>, {45, 60}  // this one causes a crash
thumbnail #2 finished loading from lib
result #3: <UIImage: 0x13a444790>, {60, 45}  // this one works

看到图案了吗?括号里的数字是什么意思?关于修复的任何想法?谢谢!

更新
我将解包array[i] as! UIImage与转换分开,它可以正常工作。即使我将其切换为UIImageJPEGRepresentation.

4

0 回答 0