내가 참고로 this site를 사용하여 오전 UIImagePickerController
메모리
에서 포착 된 이미지에서 GPS를 데이터를 가져 오기 위해 시도하는 오전에 이미지를로드하지 않고 이미지 속성 액세스.
선택한 이미지를 선택한 후에 CGImageSourceRef
은 항상 null입니다. 여기
정보의 출력입니다 : { UIImagePickerControllerMediaType = "public.image"; UIImagePickerControllerOriginalImage = "크기 {2448, 3264} 오리온 3 눈금 1.000000"; UIImagePickerControllerReferenceURL = "assets-library : //asset/asset.JPG? id = B01DF2C7-B954-41D8-B3FE-6096706DF3BB & ext = JPG"; }
imageFileURL : 자산 라이브러리 : //asset/asset.JPG ID = B01DF2C7-B954-41D8-B3FE-6096706DF3BB & 내선 = JPG
ImageSource 여기
가 널이었다 내 코드 :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSLog(@"Info: %@", info.description);
[picker dismissViewControllerAnimated:YES completion:^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *imageFileURL = (NSURL*) info[UIImagePickerControllerReferenceURL];
NSLog(@"imageFileURL: %@", imageFileURL.description);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef) imageFileURL, NULL);
if (imageSource == NULL) {
NSLog(@"ImageSource was Null");
return;
}
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)options);
CFRelease(imageSource);
CFDictionaryRef gps = CFDictionaryGetValue(imageProperties, kCGImagePropertyGPSDictionary);
if (gps) {
NSString *latitudeString = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitude);
NSString *latitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitudeRef);
NSString *longitudeString = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitude);
NSString *longitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitudeRef);
NSLog(@"GPS Coordinates: %@ %@/%@ %@", longitudeString, longitudeRef, latitudeString, latitudeRef);
}
dispatch_async(dispatch_get_main_queue(), ^{
}); //distpach get main queue
});//background queueu
}];//picker completion
}
나는 내가 뭘 잘못 모르겠습니다. 어떤 도움이 필요합니까?
불행히도 iOS9를 다시 지원해야하며 iOS 11에서만 사용할 수 있습니다. –
그건 짜증나. 나는 원래의 방법에 가깝게 뭔가를 사용하여 내 솔루션으로 대답을 업데이 트했습니다. 내가 사용하는 URL은 UIImagePickerControllerReferenceURL 대신 UIImagePickerControllerImageURL입니다. 또한 통 신당 설탕과 수신자 부담 브리징이 진행됩니다. – Dare
사용이 중단 된 것이 작동하지 않는다는 의미는 아닙니다. API가 곧 중단 될 예정임을 의미합니다. 그래서 iOS11에서 UIImagePickerControllerReferenceURL을 사용하는 것이 좋습니다. – GeneCode