首页 > 移动平台 > 详细

iOS 从相册中拿到 图片名 ,截取后缀,图片名

时间:2016-07-25 13:08:05      阅读:678      评论:0      收藏:0      [点我收藏+]

 //从路径中获得完整的文件名 (带后缀) 对从相册中取出的图片,视频都有效。

   NSString *fileName = [filePath lastPathComponent];

 

   //获得文件名 (不带后缀)

   NSString *fileName1 = [filePath stringByDeletingPathExtension];

 

   //获得文件的后缀名 (不带‘.‘)

   NSString *suffix = [filePath pathExtension];

    

 

 

 

 

//    拿到图片名字  亲测只对图片有效

   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];

       DNLog(@"[imageRep filename] : %@", [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];

    [picker dismissViewControllerAnimated:YES completion:nil];

iOS 从相册中拿到 图片名 ,截取后缀,图片名

原文:http://www.cnblogs.com/soulDn/p/5703029.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!