从iOS 8中的PHAsset获取文件扩展名?

Rob*_*way 3 xcode objective-c ios ios8

有没有办法区分PHAsset的文件扩展名?我的应用需要知道照片是否是.GIF.我没有看到任何方法这样做.

小智 8

更好的方法是使用uniformTypeIdentifier.文件可以命名为任何内容,可能包含也可能不包含文件扩展名.

[asset valueForKey:@"uniformTypeIdentifier"];
Run Code Online (Sandbox Code Playgroud)

  • 它是私有API吗? (3认同)

Ada*_*G J 5

使用 valueForKey:您可以从使用“pathExtension”提取文件扩展名的文件中获取 PHAsset 文件名,例如:PHAsset *selectedAsset = ...

NSString *fileName =[selectedAsset valueForKey:@"filename"];
NSString * fileExtension = [fileName pathExtension];
Run Code Online (Sandbox Code Playgroud)