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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM