[英]How to post to my Facebook wall without saving the image to a photo album
I'm using the following method to share an image and a url to the user's Facebook wall. 我正在使用以下方法将图片和网址共享到用户的Facebook墙。 The problem is that because I'm adding an image with the post it ends up being saved in a Facebook photo album.
问题在于,因为我要添加带有帖子的图像,所以最终将其保存在Facebook相册中。 Perhaps this is the default behaviour, although I swear at one point it was posting just to the wall with a photo and not to a photo album.
也许这是默认的行为,尽管我发誓它只是在墙上贴照片而不是在相册上发誓。
thanks for any help 谢谢你的帮助
- (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];
}
looks like it might be an FB bug. 看起来可能是FB错误。 sometimes they save to the albums sometimes not Unable to post image into facebook using SLComposeViewController?
有时他们保存到相册中有时不是无法使用SLComposeViewController将图像发布到Facebook吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.