使用UIImage作为@"图片"分享facebook对话框

Ban*_*kul 1 facebook objective-c cocos2d-iphone ios

这是简单的代码

UIImage *ScreenShot = [self getScreenshot];

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Name", @"name",
                               @"Caption.", @"caption",
                               @"Description.", @"description",
                               @"www.example.com", @"link",
                               ScreenShot, @"picture",               
                               nil];

[ facebook dialog:@"feed"
                  andParams:params
                andDelegate:self];
Run Code Online (Sandbox Code Playgroud)

当我编译它时得到这个消息

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x1288bb90' *** First throw call stack:
Run Code Online (Sandbox Code Playgroud)

Par*_*iya 5

您无法直接将图像上传到墙上,当发布到墙上时,您只需将图像链接到墙上即可.所以,你需要先在某处上传UIImage.你有2个选择:

  1. 上传到您/某个服务器并发布链接到它的墙贴.
  2. 上传到Facebook相册.检查图API有关这样做,这非常简单