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 환경에서 사진의 이름을 얻을 수 있습니까? 그렇다면 어떻게해야합니까?
[UIImagePicker에서 선택한 이미지 이름을 얻는 방법?] (http://stackoverflow.com/questions/11471254/how-to-get-uiimagepicker-selected-image-name) –
@DipenPanchasara 그 복제본은 ' 여기에 신청하십시오. 이 질문은 사진 라이브러리에서 사진을 선택하지 않고 카메라로 사진을 찍는 것에 관한 것입니다. – rmaddy