문제

I have an app where I save the current view as an image using the following code:

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
savedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Now I want to be able to post this image to Facebook. I have the following code:

if([SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook]) {

        slComposeView = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [slComposeView addImage: [UIImage imageNamed:savedImg]];
        [self presentViewController:slComposeView animated:YES completion:NULL];
}

Obviously this is wrong because I cannot pass UIImage to an NSString. What is the correct way to do it?

도움이 되었습니까?

해결책

Get rid of the imageNamed call and pass the savedImg variable directly into the addImage call.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top