2013-04-25 74 views
1

我在編寫類似於電子郵件的應用程序。因此,當我將文件附加到我的消息中時,我想顯示文件名+小圖像(圖標),此圖標應該根據文件類型,例如pdf如果文件是pdf,則Word ID文件是文件。 ...圖像文件擴展名Xcode

任何人都知道我該如何找到這些小圖像?還是有代表性的例子?

高級感謝

+0

我已經加入iOS和OSX等標籤,你可以改變你的目標操作系統。 – 2013-04-25 08:26:17

+0

我記得有關QLPreviewController中默認圖標的閱讀。另請參閱DocInteraction示例項目 – 2013-04-25 08:35:07

回答

2

如果這是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... 
}