在我的应用程序中,我必须使用照片库中的照片,我可以从库中获取照片并可以在我的应用程序中使用它,但我无法获取所选图像的名称
我正在使用这个
//accessing photo library like this
-(IBAction)btnAttachFileClicked:(id)sender
{
if([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
//to get name of the selected image i'm using this
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
{
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
__block NSString *fileName = nil;
ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
fileName = [asset.defaultRepresentation filename];
} failureBlock:nil];
}
但是从这段代码在模拟器上测试时我无法获得图像名称,我导入了 AssetsLibrary 框架,是否有任何修改需要帮助我
我将assetUrl作为“assets-library://asset/asset.PNG?id=8542B1A1-7EAD-4CCB-A85B-8450826B49FA&ext=PNG”