我需要能够在 Instagram 以及 UIActivityViewController
提供的所有选项中分享照片 - Facebook、Twitter、邮件等。我设法通过 UIDocumentInteractionController
,但需要将所有选项放在一个地方。我将自定义 UIActivity
添加到 UIActivityViewController
事件中,但不知道如何从那里直接进入 Instagram。现在它只提供与 Instagram 选项类似的菜单,因为我提供了一个 UIDocumentInteractionController
。有没有办法在一个菜单中包含所有选项?
最佳答案
感谢:Sharing image to Whatsapp & Facebook接受的回应。
看起来这个选项实际上是开箱即用的 UIDocumentInteractionController
,但我错误地展示了 Controller 。显示所有选项的正确方法是使用:-presentOptionsMenuFromRect:inView:animated:
而不是 -presentOpenInMenuFromRect:inView:animated:
UIDocumentInteractionController
不允许像 UIActivityViewController
那样省略某些选项,但我需要将 Instagram 与其他选项一起使用,所以这是可行的方法。
我使用的代码:
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"MyImage.png"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
docIntController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
docIntController.delegate = self;
[docIntController presentOptionsMenuFromRect:CGRectMake(1, 1, 1, 1) inView:self.view animated:YES];
关于ios - 将 UIDocumentInteractionController 与 UIActivityController 结合起来分享到 Instagram、Facebook、邮件、消息等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34346082/