zoukankan      html  css  js  c++  java
  • iOS 使用系统相册获取选取图片的名称

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
        
        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
        //1.选择的是图片资源
        if ([mediaType isEqualToString:@"public.image"]) {

          if (img !=nil) {

                //获取图片的名字

                __block NSString* imageFileName;

                NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];

                NSLog(@"imgurl:%@",imageURL);

                __weak typeof(self) weakSelf = self;

                ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)

                {

                    ALAssetRepresentation *representation = [myasset defaultRepresentation];

                    imageFileName = [representation filename];

                };

                ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];

                [assetslibrary assetForURL:imageURL

                               resultBlock:resultblock

                              failureBlock:nil];

            }

        }
    }
  • 相关阅读:
    numpy基本使用2
    python 继承 多态
    动态规划算法题(5题)
    利用栈非递归实现块排
    数据结构
    对Node的优点和缺点提出了自己的看法?
    前后端交互流程,如何进行交互
    Web App、Hybrid App与Native App的设计差异
    什么叫优雅降级和渐进增强?
    常用博客
  • 原文地址:https://www.cnblogs.com/guchunli/p/6654882.html
Copyright © 2011-2022 走看看