Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在应用程序中截图并将其发布到facebook上?_Iphone_Image_Facebook_Uiimage_Screenshot - Fatal编程技术网

Iphone 如何在应用程序中截图并将其发布到facebook上?

Iphone 如何在应用程序中截图并将其发布到facebook上?,iphone,image,facebook,uiimage,screenshot,Iphone,Image,Facebook,Uiimage,Screenshot,我试图在我的应用程序中使用facebook,方法是在我的墙上发布我的应用程序的截图 我已经做了截图的功能 UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageC

我试图在我的应用程序中使用facebook,方法是在我的墙上发布我的应用程序的截图

我已经做了截图的功能

UIGraphicsBeginImageContext(self.view.bounds.size);
            [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();

            UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
在我的facebook墙上贴上图标、标题和小说明

- (void)postToWall {


    FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
    dialog.userMessagePrompt = @"Enter your message:";
    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ share's a photo\",\"href\":\"mywebsite.com/\",\"caption\":\"%@thinks this is a nice photo\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"mywebsite.com/icon.png\",\"href\":\"mywebsite.com/\"}]}",
                         _facebookName, _facebookName];

    dialog.actionLinks = @"[{\"text\":\"Get My App\",\"href\":\"http://itunes.apple.com//\"}]"; 
}

有没有关于如何将我的截图放入postToWall方法的建议?提前谢谢

看来你不可能完全通过Facebook做到这一点。你应该看看照片分享网站。首先将你的图片上传到该站点并获取链接。然后通过这个方法分享它

编辑

我不是说照片上传不可能。如果不先上传,就不可能将照片和应用程序链接一起发布到墙上。

使用Facebook的iPhone SDK,这是可能的。您将需要构造和参数块(NSDictionary)并将其发送到您已验证的Facebook会话

在这里的代码片段中,“session”是在SDK的Facebook.h中定义的Facebook*类型

NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:captionText forKey:@"caption"];
[args setObject:messageText forKey:@"message"];
[args setObject:UIImageJPEGRepresentation(yourImage, 0.7) forKey:@"picture"];

[session requestWithMethodName:@"photos.upload" andParams:args ndHttpMethod:@"POST" andDelegate:self];