我有一个应用程序,我使用以下代码将当前视图保存为图像:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
savedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
现在我希望能够将此图片发布到Facebook。我有以下代码:
if([SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook]) {
slComposeView = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[slComposeView addImage: [UIImage imageNamed:savedImg]];
[self presentViewController:slComposeView animated:YES completion:NULL];
}
显然这是错误的,因为我无法将UIImage传递给NSString。这样做的正确方法是什么?
答案 0 :(得分:1)
删除imageNamed调用并将savedImg变量直接传递给addImage调用。