2016-09-28 2 views
1

두 개의 날짜 범위와 I am getting the images successfully 사이의 사진 라이브러리에서 이미지를 가져 오려고합니다.iOS에서 PHAsset을 사용하여 이미지의 위도와 경도를 얻는 방법은 무엇입니까?

그리고 아래의 코드를 사용하여 이미지 정보를 얻고 있습니다.

PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init]; 
     options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed 

     [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) { 
      CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL]; 

      //NSLog(@"fullImage=%@", fullImage.properties.description); 


     }]; 

하지만 이미지 정보는 나를 문자열 형식으로 표시합니다.

NSDictionary 형식 (위도 및 경도 얻기)으로 변환하려고했지만 null 출력이 발생했습니다.

어떻게 이미지의 위도와 경도를 얻을 수 있습니까?

얻을 수있는 또 다른 방법이 있는지 정보가

가 사전에 감사합니다 좀 도와주세요

답변

1

당신은 이미 당신이 말하는 것처럼, 당신이합니다 (PHAssets이있는 경우 다른 작업을 수행 할 필요가 없습니다 성공적으로 검색).

당신의 PHAsset의 재산은 .location입니다. 이것은 기본적으로 CLLocation의 인스턴스입니다. 이미 성공적으로 PHFetchResult를 입수했기 때문에 이제 PHAsset 개체를 가져온 다음 가능한 경우에서 위치 정보를 얻기 위해이를 반복 할 필요가

asset.location.coordinate.longitude 

또는

asset.location.coordinate.latitude 

을 : 당신은 그것을 좋아 사용할 수 있습니다 . 사전의 형태로 PHAsset에서 GPS 정보를 얻으려면이 방법을 추가

-(NSMutableDictionary *) getGPSInformationForAsset: (PHAsset *) asset 
{ 
    NSString *longitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.longitude]; 
    NSString *latitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.latitude]; 
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; 
    [dic setValue:longitude forKey:@"longitude"];//Perform proper validation here for whatever your requirements are 
    [dic setValue:latitude forKey:@"latitude"]; 
    return dic; 
} 

지금과 같은이 방법을 사용 : 그거야

NSMutableDictionary *coordinatesDictionary = [self getGPSInformationForAsset:asset]; 

을, 당신은 사전에 위도와 경도를 얻었다.

관련 문제