我從一張圖像中發現了一些關於使用ALAssetslibrary的gps的exif信息。我可以正確顯示整個退出信息,但是當我嘗試僅取得緯度時,我總是收到空。 這是關於GPS的EXIF信息:Objective-C/ALAssetslibrary - 從圖像exif信息中獲取gps緯度
"{GPS}" = {
Altitude = 0;
AltitudeRef = 1;
DateStamp = "0111:06:09";
Latitude = "45.84633333333333";
LatitudeRef = N;
Longitude = "12.58";
LongitudeRef = E;
TimeStamp = "10:39:04.00";
};
這是我使用的外帶信息代碼:
__block NSConditionLock * assetsReadLock = [[NSConditionLock alloc] initWithCondition:WDASSETURL_PENDINGREADS];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
__block ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
__block NSString *description = [[NSString alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
if (asset){
NSDictionary *data = [[asset defaultRepresentation] metadata];
NSLog(@"DATA: %@", data);
NSNumber *width = [[[asset defaultRepresentation] metadata] objectForKey:@"PixelWidth"];
NSString *widthString = [NSString stringWithFormat:@"%@", width];
[widthList addObject:widthString];
NSNumber *height = [[[asset defaultRepresentation] metadata] objectForKey:@"PixelHeight"];
NSString *heightString = [NSString stringWithFormat:@"%@", height];
[heightList addObject:heightString];
NSString *latitude = [[[asset defaultRepresentation] metadata] objectForKey:@"Latitude"];
NSLog(@"latitude %@", latitude);
NSString *latitudeString = [NSString stringWithFormat:@"%@", latitude];
if(latitude != NULL){
[latitudeList addObject:latitude];
} else {
NSString *noLatitude = [[NSString alloc] init];
noLatitude = @"No latitude available";
[latitudeList addObject:noLatitude];
}
}
}];
}
好了,在這一點上,我可以很容易地花費大約寬度信息和圖像的高度,但當我嘗試採取緯度或經度我總是收到空。我做錯了什麼?
感謝您的幫助!