我能够从 PHFetchResults 成功获取图像并将其加载到 UIImage 中,但是当我尝试获取图像的位置时,出现错误:
- 运行时 NSLog 语句中的“致命错误:在展开可选值时意外发现 nil”。
var imageAsset:PHAsset = self.photosAssetFetchResult[self.index] as PHAsset
NSLog("Location is %@", imageAsset.location)
如果我NSLog
用以下语句替换上述语句以获取描述(或任何其他属性,如长度、像素尺寸等 NSLog 正确返回它),它不会引发错误。
NSLog("Description is %@", imageAsset.Description)
我尝试使用 PHImageManger.requestImageDataForAsset 等。我得到了许多其他属性,如下所示,但位置。
[{Exif}: {
ColorSpace = 1;
ComponentsConfiguration = (
1,
2,
3,
0
);
ExifVersion = (
2,
2,
1
);
FlashPixVersion = (
1,
0
);
PixelXDimension = 1280;
PixelYDimension = 960;
SceneCaptureType = 0;
}, ColorModel: RGB, DPIWidth: 72, Depth: 8, Orientation: 1, DPIHeight: 72, PixelHeight: 960, PixelWidth: 1280, {TIFF}: {
Orientation = 1;
ResolutionUnit = 2;
XResolution = 72;
YResolution = 72;
}]
请指教。