2017-10-17 78 views
1

我有一個UIDocumentPickerViewController用下面的代碼:UIDocumentPickerViewController的文件來禁用?

UIDocumentPickerViewController *documentPicker = 
    [[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"public.text", @"public.sql"] 
                   inMode: UIDocumentPickerModeOpen]; 

documentPicker.delegate = self; 
documentPicker.modalPresentationStyle = UIModalPresentationOverFullScreen; 
[self presentViewController: documentPicker 
        animated: YES 
       completion: nil]; 

這將打開選擇器,我可以選擇.txt文件,但我不能挑.sql文件。以下屏幕截圖顯示了.sql文件在選取器中的外觀。

UIDocumentPickerViewController files disabled

我已經添加下面我info.plist文件,該文件以我的理解,可能需要(忽略UTTypeReferenceURL,我只是試圖讓這個工作。)

<key>UTExportedTypeDeclarations</key> 
<array> 
    <dict> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.sql</string> 
      <string>public.data</string> 
     </array> 
     <key>UTTypeDescription</key> 
     <string>SQL statement(s)</string> 
     <key>UTTypeIconFile</key> 
     <string>public.sql</string> 
     <key>UTTypeIdentifier</key> 
     <string>public.sql</string> 
     <key>UTTypeReferenceURL</key> 
     <string>http://www.w3.org/Graphics/JPEG/</string> 
    </dict> 
</array> 

我需要做什麼做有UIDocumentPickerViewController允許採摘.sql文件類型?

回答

1

我能夠基於另一個問題here弄明白。我增加了以下我的info.plist:

<array> 
    <dict> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.data</string> 
     </array> 
     <key>UTTypeDescription</key> 
     <string>SQL statements</string> 
     <key>UTTypeIdentifier</key> 
     <string>com.hankinsoft.sqlpro.sql</string> 
     <key>UTTypeTagSpecification</key> 
     <dict> 
      <key>public.filename-extension</key> 
      <string>sql</string> 
     </dict> 
    </dict> 
</array> 

而且修改了我的UIDocumentPickerViewController是如下:

UIDocumentPickerViewController *documentPicker = 
    [[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"com.hankinsoft.sqlpro.sql"] 
                  inMode: UIDocumentPickerModeOpen]; 
0

你有到位的public.sql使用public.database

+0

'public.database'沒有任何解決問題。我在想這可能是用於sqlite數據庫文件而不是sql腳本。 – Kyle

相關問題