//從路徑中獲得完整的文件名 (帶后綴) 對從相冊中取出的圖片,視頻都有效。
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];