ALAsset时间戳返回错误的日期

Rex*_*c66 3 iphone objective-c assetslibrary alasset

我想获取图像的时间戳,我可以得到正确的纬度和经度值,但时间戳总是返回当前时间,而不是图像的EXIF时间.

ALAssetsLibraryAssetForURLResultBlock resultsBlock = ^(ALAsset *asset) {
    CLLocation *imageLoc = [asset valueForProperty:ALAssetPropertyLocation];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"dd/MM/YY HH:mm:ss"];
    NSString *trailTime = [formatter stringFromDate:imageLoc.timestamp];
    NSLog(@"---+++ image TimeStamp: %@", trailTime);
    [formatter release];
Run Code Online (Sandbox Code Playgroud)

任何帮助表示感谢,谢谢

Dee*_*olu 13

您需要使用ALAssetPropertyDate密钥获取日期.

NSDate * date = [asset valueForProperty:ALAssetPropertyDate];
/* Use the `NSDateFormatter` instance to print the date */
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,这将返回保存图像的日期/时间.因此,如果说图像被编辑或使用照片应用程序拍摄然后转移到相机胶卷,则日期/时间将是错误的 (2认同)