2017-06-16 19 views
2

我創建了iOS 11的應用程序與UIDocumentViewController(從Xcode 9模板)。 我註冊了支持.swift文件(public.swift-script)的文檔類型,它可以在原地打開和使用文件應用程序,但在應用程序的瀏覽器中,禁用擴展名爲.swift的文件,我無法選擇它們。UIDocumentBrowserViewController與UTI的錯誤

我不知道是否是一個iOS 11的bug或我,因爲它是工作,如果我設置文檔類型與public.item文件工作。

注意:同樣的事情發生,如果我允許選擇多個項目,但如果我點擊'全選',文件正常選擇。

回答

1

我可能沒有我需要的所有信息,但使用的模板,我對你的問題的所有我需要做的理解是UTI添加到Info.plist中是這樣的:

通過源

<key>CFBundleDocumentTypes</key> 
<array> 
    <dict> 
     <key>CFBundleTypeIconFiles</key> 
     <array/> 
     <key>CFBundleTypeName</key> 
     <string>Source Code</string> 
     <key>CFBundleTypeRole</key> 
     <string>Editor</string> 
     <key>LSHandlerRank</key> 
     <string>Alternate</string> 
     <key>LSItemContentTypes</key> 
     <array> 
      <string>public.swift-source</string> 
     </array> 
    </dict> 
    <dict/> 
</array> 

Via the GUI

如果我誤解了你的問題,讓我知道。

+0

哇,謝謝,它的工作,我添加public.swift-script而不是public.swift-source,與public.swift-source它的工作 – ColdGrub1384

+0

@ ColdGrub1384 [Here](https://developer.apple.com/library /content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html)是我從中拉出UTI。 –

+0

@ ColdGrub1384如果它解決了您的問題,請接受此答案 –