0

我想将图像分享到 Facebook,我正在使用以下代码:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [slComposeViewController addImage:[UIImage imageNamed:@"BottletoBottle.jpg"]];
    [slComposeViewController addURL:[NSURL URLWithString:facebookURL]];
    [slComposeViewController setInitialText:facebookstarRating];
    [self presentViewController:slComposeViewController animated:YES completion:NULL];

}else{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook Alert" message:@"You have no facebook account signed in" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
    [alert show];
}

这样,代码可以完美运行,但我想替换该行:

[slComposeViewController addImage:[UIImage imageNamed:@"BottletoBottle.jpg"]];

和:

NSString *facebookImageName = @"BottletoBottle.jpg";
[slComposeViewController addImage:[UIImage imageNamed:facebookImageName]];

但它不工作。你能帮我解释一下为什么这个设置不起作用。非常感谢

4

0 回答 0