在我的应用程序中,我允许用户通过 Instagram 分享照片,这需要使用 UIDocumentInteractionController。如果手机支持,则会自动检测空投。如何从这个“打开方式”操作表中删除它?
即使我使用 UIActivityViewController 开始共享过程并调用 setExcludedActivityTypes:,最终我也必须使用 UIDocumentInteractionController,当我这样做时,Airdrop 再次出现。以下是点击分享按钮时的代码:
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");
}