我有一个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文件在选择器中的样子。
我已将以下内容添加到我的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文件类型,我需要做些什么?
答案 0 :(得分: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];
答案 1 :(得分:0)
您必须使用public.database
代替public.sql
。