ios - 将 UIDocumentInteractionController 与 UIActivityController 结合起来分享到 Instagram、Facebook、邮件、消息等

标签 ios share instagram uiactivityviewcontroller uidocumentinteraction

我需要能够在 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/

相关文章:

c++ - 在 Visual Studio C++ 中从一个项目访问变量到另一个项目

ios - 在滑动手势、iOS、Swift 上将 View 更改为圆圈

ios - 我已经使用 xib 在 swift 中创建了一个 TableView ,但是当我运行该应用程序时它显示错误

iOS不同的bundle id映射到同一个应用程序

ios - 如何使用嵌套数据创建结构

php - Instagram API。 "Unable to reach callback url"

ios - 将 TableView 选定的数据分享到whatsapp

Android/Google Plus - 无法分享来 self 的内容提供商的图片

api - 客户端 ID 的 Instagram 速率限制是否仅适用于未经身份验证的 API 请求?

javascript - 本地主机不存在 Access-Control-Allow-Origin