UIDocumentPickerViewController 文件已禁用?
UIDocumentPickerViewController files disabled?
我有一个 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 文件类型?
您必须使用 public.database
代替 public.sql
。
我是根据另一个问题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];
我有一个 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 文件类型?
您必须使用 public.database
代替 public.sql
。
我是根据另一个问题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];