zoukankan      html  css  js  c++  java
  • iOS 从相册中拿到 图片名 ,截取后缀,图片名

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

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

  • 相关阅读:
    小程序 的授权登陆
    ant desgin pro 项目中的 数据流方案
    new Date() 日期格式处理
    小程序手写 的选择日期 区间
    小程序中的slot(插槽)
    微信小程序实现城市选择和城市切换
    微信小程序 使用页面栈 修改上一个页面的data数据
    2021/2/25
    2021/2/24
    2021/2/23
  • 原文地址:https://www.cnblogs.com/soulDn/p/5703029.html
Copyright © 2011-2022 走看看