標籤:
//從路徑中獲得完整的檔案名稱 (帶尾碼) 對從相簿中取出的圖片,視頻都有效。
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 從相簿中拿到 圖片名 ,截取尾碼,圖片名