我想与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]];
但它不起作用。你能帮我解释为什么这个设置不起作用。非常感谢