-1

我学习了这个示例代码,并尝试在我的应用程序中实现,但照片无法显示。

在此处输入链接描述

在此处输入图像描述

在此处输入图像描述

- (IBAction)facebookBtn_down:(id)sender {
if (osVer >= 6.0) {
    SLComposeViewController *fbVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [fbVC setInitialText:apple_F_MSG];
    [fbVC addURL:[NSURL URLWithString:APP_URL]];
    [fbVC setCompletionHandler:^(SLComposeViewControllerResult res) {

        if (res == SLComposeViewControllerResultDone) [self AlertToukou];
    }];
    [self presentModalViewController:fbVC animated:YES];
} else {
    DEFacebookComposeViewController *fbVC = [[[DEFacebookComposeViewController alloc] init] autorelease];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [fbVC setInitialText:apple_F_MSG];
    [fbVC addURL:[NSURL URLWithString:APP_URL]];
    [fbVC setCompletionHandler:^(DEFacebookComposeViewControllerResult res) {
        if (res == DEFacebookComposeViewControllerResultDone) [self AlertToukou];
        [self dismissModalViewControllerAnimated:YES];
        self.modalPresentationStyle = UIModalPresentationFullScreen;
    }];
    [self presentModalViewController:fbVC animated:YES];
}

}

请给我一些建议,谢谢!

4

2 回答 2

1

从它的文档页面上说,

DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[facebookViewComposer setInitialText:@"Look on this"];
[facebookViewComposer addImage:[UIImage imageNamed:@"1.jpg"]];//<------Check This
facebookViewComposer.completionHandler = completionHandler;
[self presentViewController:facebookViewComposer animated:YES completion:^{ }]; 

您应该使用addImage功能并提供适当的UIImage对象而不是它应该工作的对象。

于 2013-04-17T08:10:28.803 回答
0

我发现了问题:</p>

我没有设置 Key "forKey:@"source",不能贴在墙上

errorError Domain=com.facebook.sdk Code=5 "操作无法完成。(com.facebook.sdk error 5.)"

if ([self.images count] > 0) {
        [d setObject:UIImagePNGRepresentation([self.images lastObject]) forKey:@""];
        graphPath = @"me/photos";
    }
于 2013-04-18T03:06:55.893 回答