UIDocumentInteractionController阻止“打开”工作表中的Airdrop

在这里输入图像说明

在我的应用程序中,我允许用户通过Instagram分享照片,这需要使用UIDocumentInteractionController。 如果手机支持Airdrop,会自动检测。 我如何从这个“打开”操作表中删除它?

即使我开始与UIActivityViewController的共享过程,并调用setExcludedActivityTypes:,最终我必须使用UIDocumentInteractionController,当我这样做,Airdrop再次出现。 这是分享button被点击时的代码:

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.igo"]; NSData *imageData = UIImagePNGRepresentation(imageToShare); [imageData writeToFile:savedImagePath atomically:YES]; NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath]; docController = [[UIDocumentInteractionController alloc] init]; docController.UTI = @"com.instagram.exclusivegram"; docController.URL = imageUrl; [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; } else { NSLog(@"no insta"); } 

据我可以告诉你不能。 我也需要禁用这个选项。 但是在UIDocumentInteractionController上它是完全无法访问的。 在我的书中很糟糕的API经验。

如果用户在列表中select一个应用程序,您的应用程序将获得callback

 -(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application -(void)documentInteractionController: (UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application 

如果用户selectAirDrop,则根本不会收到通知。

这一切都无法消除,苹果仍然在试图使空投到处都是,所以我们今后可能会在更less的地方看到。 从7.1更新,它肯定会进入UIDocumentInteractionController而不pipe空投状态(在设备上开或关)

还有一件坏事是空投分享没有callback,这意味着你的应用永远不知道共享状态。 下面的2名代表将无法共享。

 -(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application -(void)documentInteractionController: (UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application 

我希望苹果会公开一些委托方法,以便在将来的版本中实现这一点。