gpt4 book ai didi

ios - UIDocumentMenuViewController initWithDocumentTypes :inMode: can only be called with mode Import or Open

转载 作者:行者123 更新时间:2023-12-01 19:17:01 24 4
gpt4 key购买 nike

在我的 iOS 应用程序中,我打开一个 UIDocumentMenuViewController。当我使用 UIDocumentPickerModeImport 模式调用它时,一切正常(我的所有 iCloud 权利均已设置)。

但是,当我使用 UIDocumentPickerModeExportToService 调用它时,应用程序崩溃并出现以下错误:

Assertion failure in -[UIDocumentMenuViewController initWithDocumentTypes:inMode:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.6.22/UIDocumentMenuViewController.m:71

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIDocumentMenuViewController initWithDocumentTypes:inMode:] can only be called with mode Import or Open'

我做错了什么?为什么只能用导入或打开模式调用?

我的代码:

UIDocumentMenuViewController *exportMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[@"public.image"]
inMode:UIDocumentPickerModeExportToService];

exportMenu.delegate = self;
[self presentViewController:exportMenu animated:YES completion:nil];

这种情况发生在模拟器和我测试过的两台设备上(均运行 iOS 10)。

任何帮助将不胜感激!

最佳答案

我刚刚找到了答案:当想要导出时,您需要使用不同的初始化方法:initWithURL:inMode:

我希望在这种情况下异常(exception)会更有帮助:)

关于ios - UIDocumentMenuViewController initWithDocumentTypes :inMode: can only be called with mode Import or Open,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42989567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com