Note that there are some explanatory texts on larger screens.

plurals
  1. POfacebook ios sdk - trouble posting photo using UIImage
    text
    copied!<p>I'd be grateful for any suggestions as to how to deal with a problem I'm having posting an image to Facebook.</p> <p>The following code works just as I would expect:</p> <pre><code>NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"http://myserver/img.png", @"picture", @"My Testing", @"name", @"Enter some text...", @"message", nil]; [appDelegate.facebook dialog:@"feed" andParams:params andDelegate:self]; </code></pre> <p>However, I really want to use an image that I capture from my camera. I've set up the code to do that earlier in my application and I've put the image on the screen. So, I tried to do this: </p> <pre><code>CGRect contextRect = CGRectMake(0, 0, 320, 436); UIGraphicsBeginImageContextWithOptions(contextRect.size, YES, 1); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>I've tested this code and newImage is a valid UIImage that I can place and manipulate just as I'd expect. However, when I try to integrate it into the Facebook dialog as follows:</p> <pre><code>NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: newImage, @"picture", @"My Testing", @"name", @"Enter some text...", @"message", nil]; [appDelegate.facebook dialog:@"feed" andParams:params andDelegate:self]; </code></pre> <p>I get these two ridiculous messages in the console: -[UIImage length]: unrecognized selector sent to instance 0x1c9420 CoreAnimation: ignoring exception: -[UIImage length]: unrecognized selector sent to instance 0x1c9420</p> <p>So, as a test, I thought I'd try importing an image into my project and accessing it directly. This is the exact image as I referenced online in the first example, so I know it should work. But even when I try this: </p> <pre><code>UIImage *newImage = [UIImage imageNamed:@"BaB.png"]; </code></pre> <p>I get the same error messages as above.</p> <p>I see in the Facebook documentation that the "picture" key is supposed to use the URL to an image. But I've seen some examples online that indicate that folks are using an UIImage instead of just an URL. </p> <p>Clearly, I'm doing something wrong, but I have no idea what it might be. </p> <p>I'd be very grateful for any pointers as to how to proceed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload