UIDocumentPickerViewController - 所有文件都显示为灰色 [英] UIDocumentPickerViewController - All files grayed out

查看:3437
本文介绍了UIDocumentPickerViewController - 所有文件都显示为灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS 8中测试新的 UIDocumentPickerViewController API。我想在iCloud中打开一个文件,看看交互是如何工作的。



这是我从 UIViewController 运行的代码:

   - (IBAction)openDocument:(id)sender {
[self showDocumentPickerInMode:UIDocumentPickerModeOpen];
}

- (void)showDocumentPickerInMode:(UIDocumentPickerMode)模式{
UIDocumentPickerViewController * picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@ [(NSString *)kUTTypeData] inMode:mode ]。

picker.delegate = self;

[self presentViewController:picker animated:YES completion:nil];
}

openDocument 并列到IB的按钮。当我点击它时,它会打开iCloud浏览器,但其中的每个文件夹都显示为灰色(我创建了一些测试Keynote,Numbers和Pages文件),所以我无法访问这些文件:





<我检查了一些文档并做了以下事情(没有运气):




  • 在我的应用程序中启用了iCloud(在功能部分,密钥值存储和iCloud文档)。

  • 在我的Info.plist中添加了 public.data 的UTI作为如下:

     < key> CFBundleDocumentTypes< / key> 



    CFBundleTypeIconFile
    icon.png
    CFBundleTypeName
    MyData
    CFBundleTypeRole
    查看器
    LSItemContentTypes

    public.data

    LSTypeIsPackage

    NSDocumentClass
    凭证
    NSPersistentStoreTypeKey
    二进制


  • 添加 NSUbiquitousContainerIsDocumentScopePublic 键值 YES 到我的Info.plist。




知道可能出错或丢失的内容吗?

解决方案

iWork文档不符合 kUTTypeData ,它们符合 kUTTypePackage



然而,在iOS中8 beta 3,我必须使用确切的UTI:

  UIDocumentPickerViewController * picker = [[UIDocumentPickerViewContr oller alloc] initWithDocumentTypes:@ [@com.apple.iwork.pages.pages,@com.apple.iwork.numbers.numbers,@com.apple.iwork.keynote.key] inMode:mode] ; 


I'm testing the new UIDocumentPickerViewController API in iOS 8. I want to just open a file in iCloud, to see how the interaction works.

This is the code I'm running from my UIViewController:

- (IBAction)openDocument:(id)sender {
    [self showDocumentPickerInMode:UIDocumentPickerModeOpen];
}

- (void)showDocumentPickerInMode:(UIDocumentPickerMode)mode {
    UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeData] inMode:mode];

    picker.delegate = self;

    [self presentViewController:picker animated:YES completion:nil];
}

openDocument is tied to a button in IB. When I tap it, it opens the iCloud browser, but every folder in it is grayed out (I created some test Keynote, Numbers and Pages files) so I cannot get to the files:

.

I checked some documentation and did the following (with no luck):

  • Enabled iCloud in my app (in the Capabilities section, for both Key-value storage and iCloud Documents).
  • Added the UTI for public.data in my Info.plist as follows:

    <key>CFBundleDocumentTypes</key>
    

    CFBundleTypeIconFile icon.png CFBundleTypeName MyData CFBundleTypeRole Viewer LSItemContentTypes public.data LSTypeIsPackage NSDocumentClass Document NSPersistentStoreTypeKey Binary

  • Added the NSUbiquitousContainerIsDocumentScopePublic key with a value of YES to my Info.plist.

Any idea what could be wrong or missing?

解决方案

iWork documents do not conform to kUTTypeData, they conform to kUTTypePackage.

However, in iOS 8 beta 3, I had to use the exact UTIs:

UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:mode];

这篇关于UIDocumentPickerViewController - 所有文件都显示为灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆