UIDocumentInteractionController在“打开方式”表中阻止Airdrop

编程入门 行业动态 更新时间:2024-10-10 13:14:42
本文介绍了UIDocumentInteractionController在“打开方式”表中阻止Airdrop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

>

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

即使我开始与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它是完全不可访问。

如果用户在列表中选择了一个应用,您的应用会获得回调

- (void)documentInteractionController:(UIDocumentInteractionController *)控制器didBeginSendingToApplication:(NSString *)应用程序 - (NSString *)应用程序

如果用户选择AirDrop, p>

In my app, I'm allowing users to share photos via Instagram, which requires the use of UIDocumentInteractionController. Airdrop is automatically detected if the phone supports it. How do I remove it from this ‘Open in’ action sheet?

Even if I begin the sharing process with a UIActivityViewController and call setExcludedActivityTypes:, eventually I must use a UIDocumentInteractionController, and when I do, Airdrop appears again. Here is the code when the share button gets tapped:

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"); }

解决方案

As far as I can tell you can't. I need to disable this option also. But on UIDocumentInteractionController it is completely inaccessible. Pretty bad API experience in my book.

If the user selects an App in the list your App gets the callbacks

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

If the user selects AirDrop you don't get notified at all.

更多推荐

UIDocumentInteractionController在“打开方式”表中阻止Airdrop

本文发布于:2023-11-13 06:21:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   UIDocumentInteractionController   Airdrop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!