1
我能夠從PHFetchResults成功抓取圖像並將其裝載到UIImage的很好,但是當我嘗試獲取圖像的位置,我得到錯誤:照片框架 - 如何從PHAsset獲取CLLocation圖像?
- "fatal error: unexpectedly found nil while unwrapping an Optional value" at NSLog statement during runtime.
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;
}]
請指教。