UIDocumentInteractionController在某些应用程序中禁用打开 [英] UIDocumentInteractionController disable open in certain apps

查看:123
本文介绍了UIDocumentInteractionController在某些应用程序中禁用打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用UIDocumentInteractionController来打开功能。当它打开时,它会显示设备上可以处理该文件类型的所有应用程序的列表。

I'm currently using a UIDocumentInteractionController for open in functionality. When it opens it shows a list of all apps on the device that can handle that file type.

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

Is there a way to disable my app sending a document to specific apps, even if they support that file type? For example - if I have a PDF file open in my app and iBooks is on the iPad, if I tap the iBooks icon in the UIDocumentInteractionController, I don't want it to send it to the app.

理想情况下 - 我将此视为构建黑名单(或白名单)。例如,执行此操作会很棒:

Ideally - I see this as building a blacklist (or whitelist). For example, it would be great to do this:

   - (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
    }
}

这个但是,即使文件被黑名单,该文档仍然会被发送到该应用程序。

With this however, the document is still sent to the application even if it is "black listed".

这种方法是否可行?

干杯!

推荐答案

如果应用程序被列入黑名单,请将UIDocumentInteractionController的URL更改为无效值。在方法 - [UIDocumentInteractionControllerDelegate documentInteractionController:willBeginSendingToApplication:]

Change the UIDocumentInteractionController's URL to an invalid value if the app is blacklisted. In the method -[UIDocumentInteractionControllerDelegate documentInteractionController: willBeginSendingToApplication:].

-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{
    if([application isEqualToString:@"com.evilcorp.badapp"){
        controller.URL = nil;
    }
}

这篇关于UIDocumentInteractionController在某些应用程序中禁用打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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