22

使用简单的 UIActivityViewController

-(void)share{

    NSString *textToShare = _mytext;
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    UIImage *imageToShare = _myimage;
    NSArray *activityItems = @[textToShare, url,  imageToShare];
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                      applicationActivities:nil];

    [self presentViewController:activityVC animated:YES completion:nil];
}

我想在适当的地方分享文字、网址和图片。

所以如果用户选择邮件,一切都会出现。等其他应用程序(pinterest、facebook、twitter)

在 Facebook Messenger 上 - 如果共享 url 和图像,共享屏幕会崩溃。这是一个已知问题(无法发送带有 url 的图像)吗?

4

1 回答 1

1

* 编辑:更新到最新的 SDK

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = @"Your title";
content.contentDescription = @"Some description text maybe...";
content.contentURL = [NSURL URLWithString:@"http://yourlink.com"];
content.imageURL = [NSURL URLWithString:@"http://yourlink.com/theImage.png"];

[FBSDKMessageDialog showWithContent:content delegate:self];


// Delegate
- (void)sharer: (id<FBSDKSharing>)sharer didCompleteWithResults: (NSDictionary *)results 
{
    BOOL complete = [[results valueForKeyPath:@"didComplete"] boolValue];
    NSString *completionGesture = [results valueForKeyPath:@"completionGesture"];
    if (completionGesture && [completionGesture isEqualToString:@"cancel"]) {
        // action was canceled by the user
    }

    if (complete) {
        // the message/link/image was sent
    }
}

- (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    // handle error...
}

你可以试试看:)

于 2015-05-27T12:43:51.923 回答