在我的应用程序中,我允许用户通过 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");
}
据我所知你不能。我还需要禁用此选项。但在 UIDocumentInteractionController 上它是完全无法访问的。在我的书中,API 体验非常糟糕。
如果用户在列表中选择一个应用程序,您的应用程序会收到回调
-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
-(void)documentInteractionController: (UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
如果用户选择 AirDrop,您根本不会收到通知。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)