博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 从相册中拿到 图片名 ,截取后缀,图片名
阅读量:7058 次
发布时间:2019-06-28

本文共 941 字,大约阅读时间需要 3 分钟。

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

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

转载于:https://www.cnblogs.com/soulDn/p/5703029.html

你可能感兴趣的文章
数据库备份 恢复
查看>>
Jmeter
查看>>
Automatic Truncation of Virtual Log Files(VLFs的自动截断)
查看>>
[Z]寻找第K大的数的方法总结
查看>>
javascript一些常用代码块
查看>>
利用EntityFramework获得双色球数据库
查看>>
IOS4.0与5.0解决键盘的冲突
查看>>
mongo-mapreduce测试(10)——阶段总结(2)
查看>>
Setting an Oracle event:The structure of the trace syntax
查看>>
CSS+DIV:父DIV相对定位+子DIV绝对定位
查看>>
DBCC--SHRINKDATABASE
查看>>
我的开源路声明
查看>>
C# 图像处理:获取鼠标位置信息(全局)
查看>>
angular学习笔记(一)-入门案例
查看>>
jQuery hover事件鼠标滑过图片半透明标题文字滑动显示隐藏
查看>>
BackTrack5 (BT5)无线password破解教程之WPA/WPA2-PSK型无线password破解
查看>>
jQuery修改class属性和CSS样式
查看>>
Web.xml配置具体解释之context-param
查看>>
Qt Widgets——抽象按钮及其继承类
查看>>
svn 版本管理与自动部分发布(转)
查看>>