ios – UIDocumentInteractionController在某些应用程序中禁用打开

ios – UIDocumentInteractionController在某些应用程序中禁用打开,第1张

概述我目前正在使用UIDocumentInteractionController来打开功能.当它打开时,它会显示设备上可以处理该文件类型的所有应用程序的列表. 有没有办法禁用我的应用程序将文档发送到特定的应用程序,即使它们支持该文件类型?例如 – 如果我在我的应用程序中打开了PDF文件而iBooks在iPad上,如果我点击UIDocumentInteractionController中的iBooks图 我目前正在使用UIdocumentInteractionController来打开功能.当它打开时,它会显示设备上可以处理该文件类型的所有应用程序的列表.

有没有办法禁用我的应用程序将文档发送到特定的应用程序,即使它们支持该文件类型?例如 – 如果我在我的应用程序中打开了pdf文件而iBooks在iPad上,如果我点击UIdocumentInteractionController中的iBooks图标,我不希望它将其发送到应用程序.

理想情况下 – 我将此视为构建黑名单(或白名单).例如,这样做会很棒:

- (voID) documentInteractionController: (UIdocumentInteractionController *) controller willBeginSendingToApplication: (Nsstring *) application {    // if app is blackListed    if ([application isEqualToString:@"com.schimera.WebDAVNavigator"]) {        [self.interactionController dismissMenuAnimated:YES];        UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:@"FAIL" message:@"NO" delegate:nil cancelbuttonTitle:@"OK" otherbuttonTitles:nil];        [alert show];        return    }}

但是,即使它被“黑名单”,文档仍然会被发送到应用程序.

这种方法有可能吗?

干杯!

解决方法 如果应用程序被列入黑名单,请将UIdocumentInteractionController的URL更改为无效值.在方法中 – [UIdocumentInteractionControllerDelegate documentInteractionController:willBeginSendingToApplication:].

-(voID)documentInteractionController:(UIdocumentInteractionController *)controller willBeginSendingToApplication:(Nsstring *)application{    if([application isEqualToString:@"com.evilcorp.badapp"){        controller.URL = nil;    }}
总结

以上是内存溢出为你收集整理的ios – UIDocumentInteractionController在某些应用程序中禁用打开全部内容,希望文章能够帮你解决ios – UIDocumentInteractionController在某些应用程序中禁用打开所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1020793.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存