2016-06-13 3 views
0

UIImagePickerController를 사용하여 카메라로 찍은 이미지의 파일 이름을 검색하는 방법을 알고 싶습니다.UIImagePickerController를 사용하여 이미지 파일 이름을 검색하려면 어떻게해야합니까?

아무 것도 할 필요가 없습니다. 전자 메일을 보낼 때 파일을 첨부 할 때 표시되는 것과 같은 파일 이름 만 표시하면됩니다. 지금까지

, 내가 AssetsLibrary 사용하고 있습니다 :

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 

    [picker dismissViewControllerAnimated:YES completion:nil]; 

    NSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL]; 

    // define the block to call when we get the asset based on the url (below) 
    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset) 
    { 
     ALAssetRepresentation *imageRep = [imageAsset defaultRepresentation]; 
     NSLog(@"[imageRep filename] : %@", [imageRep filename]); 
     self.photoNameLabel.text = [imageRep filename]; 
    }; 

    // get the asset library and fetch the asset based on the ref url (pass in block above) 
    ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; 
    [assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil]; 


    self.photoLoaded = info[UIImagePickerControllerEditedImage]; 
    [self viewWillLayoutSubviews]; 
} 

그러나 imageAsset는 항상 장치의 카메라에서 오는 경우 nil을, 그리고 그렇지 않은 것, 이미지는 내가 다운로드 한 경우에도 IMG_00XX.jpg 이름 전에 다른 이름으로 인터넷에서.

ios 환경에서 사진의 이름을 얻을 수 있습니까? 그렇다면 어떻게해야합니까?

+0

[UIImagePicker에서 선택한 이미지 이름을 얻는 방법?] (http://stackoverflow.com/questions/11471254/how-to-get-uiimagepicker-selected-image-name) –

+0

@DipenPanchasara 그 복제본은 ' 여기에 신청하십시오. 이 질문은 사진 라이브러리에서 사진을 선택하지 않고 카메라로 사진을 찍는 것에 관한 것입니다. – rmaddy

답변

1

카메라로 사진을 찍을 때 이름이 없습니다. 거기에는 인 메모리 UIImage 인스턴스가 있습니다. 파일과 관련이 없습니다.

이 카메라 이미지를 이메일에 첨부 파일로 추가하려면 "photo.jpg"또는 "picture.jpg"또는 사용하려는 다른 이름과 같은 원하는 이름을 지정하십시오.

+0

잘 알고 있습니다. 그리고 다운로드 한 이미지의 "진짜 이름"을 얻을 수 있습니까? 지금까지, 나는 ios가 나의 다운로드 한 그림의 이름을 바꾸고 있다고 생각한다. –

+0

다운로드 한 이미지는 무엇입니까? 어디에서? 어떻게 지내니? – rmaddy

관련 문제