【问题标题】:How to post to my Facebook wall without saving the image to a photo album如何在不将图像保存到相册的情况下发布到我的 Facebook 墙上
【发布时间】:2013-03-05 11:29:59
【问题描述】:

我正在使用以下方法将图像和 url 分享到用户的 Facebook 墙。问题是因为我在帖子中添加了一张图片,它最终被保存在 Facebook 相册中。也许这是默认行为,尽管我发誓它只是在墙上张贴照片而不是相册。

感谢您的帮助

- (IBAction)shareAction:(id)sender {
    SLComposeViewController * fbController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [fbController setInitialText:@"App Name"];

     NSIndexPath* indexPath = [tableView indexPathForCell:sideSwipeCell];
  //  NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    // output id of selected deal
#ifdef DEBUG
    NSLog(@"deal id for selected row is %@", [[displayItems objectAtIndex:indexPath.row] objectForKey:@"id"]);
#endif
    // display the youdeal deal image
    link = [[displayItems objectAtIndex:indexPath.row] objectForKey:@"link"];

    // download the youdeal deal image for FB posting

    NSURL *url = [NSURL URLWithString:[[displayItems objectAtIndex:indexPath.row] objectForKey:@"image"]];
    NSLog(@"url to image share %@", url);

    NSData *data = [[NSData alloc] initWithContentsOfURL:url];

    NSLog(@"data to image share %@", data);

    UIImage *tmpImage = [[UIImage alloc] initWithData:data];

    NSLog(@"tmpImage to image share %@", tmpImage);

    ydImage = tmpImage;

    NSLog(@"ydimageview.image %@", ydImage);

  //  [NSThread detachNewThreadSelector:@selector(downloadAndLoadImage) toTarget:self withObject:nil];

    [fbController setInitialText:@"Check out this link."];
    [fbController addURL:[NSURL URLWithString:link]];
    [fbController addImage:ydImage];

    SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
        [fbController dismissViewControllerAnimated:YES completion:nil];

        switch(result){
            case SLComposeViewControllerResultCancelled:
            default:
            {
#ifdef DEBUG

                NSLog(@"User Cancelled.");
#endif
                [self removeSideSwipeView:YES];
            }
                break;
            case SLComposeViewControllerResultDone:
            {
#ifdef DEBUG
                NSLog(@"Posted");
#endif
                [self removeSideSwipeView:YES];

                CustomAlertView *fbAlert = [[CustomAlertView alloc] initWithTitle:@"App Name" message:@"Facebook Post Successful!" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];

                [fbAlert show];
            }
                break;
        }};

    [fbController setCompletionHandler:completionHandler];
    [self presentViewController:fbController animated:YES completion:nil];
}

【问题讨论】:

  • 你的意思是图片上传后保存在照片库中?
  • @RajanBalana 是的。我希望它只是向应用程序墙的用户发布链接和图像。
  • 请添加imagePickerDidFinishPickingMedia方法的代码。谢谢
  • 图片来自一个 URL,我没有使用 imagePickerDidFinishPickingMedia: 方法
  • 这可能是一个 FB 错误。有时他们保存到相册有时不是stackoverflow.com/questions/14868560/…

标签: ios objective-c facebook slcomposeviewcontroller


【解决方案1】:

看起来这可能是一个 FB 错误。有时他们保存到相册有时不是Unable to post image into facebook using SLComposeViewController?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多