我正在编写一个类似于电子邮件的应用程序。所以当我将文件附加到我的消息时,我想显示文件名+小图像(图标),这个图标应该根据文件类型,例如 pdf 如果文件是 pdf,Word id 文件是 word 文件。 ...
有人知道我怎样才能找到这些小图片吗?或者有什么代表性的例子吗?
高级感谢
最佳答案
如果这是针对 iOS 的,那么您可以使用 UIDocumentInteractionController :
NSURL *url = [NSURL fileURLWithPath:pathToYourFile];
UIDocumentInteractionController *diac = [UIDocumentInteractionController interactionControllerWithURL:url];
NSArray *icons = diac.icons;
if ([icons count] > 0) {
// This is the smallest available icon:
UIImage *icon = [icons objectAtIndex:0];
} else {
// No icon found.
// According to the documentation, this case *should not* occur...
}
关于ios - 图像文件扩展 Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16209708/