add FBConnect to your project and use the code below for general image capture on facebook. Also add the delegate FBSessionDelegate, FBDialogDelegate, FBRequestDelegate to your .h file. If you want to share a local image, you do not need to upload the image to the server. pass uiimage object to facebook settings.
if (facebook == nil) { facebook = [[Facebook alloc] initWithAppId:@"your facebook key "]; } NSArray* permissions = [NSArray arrayWithObjects: @"publish_stream", @"offline_access", nil] ; // [facebook authorize:permissions delegate:self]; - (BOOL) takeScreenshot { UIGraphicsBeginImageContext(self.view.frame.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: viewImage,@"message", nil]; [facebook requestWithGraphPath:@"me/photos" // or use page ID instead of 'me' andParams:params andHttpMethod:@"POST" andDelegate:self]; return YES; } #pragma mark - #pragma mark FBSessionDelegate /** * Called when the user has logged in successfully. */ - (void)fbDidLogin { isFBLogged = YES; [self takeScreenshot]; if([self takeScreenshot]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Image share sucessfully" message: nil delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Image share unsucessfully" message: nil delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } }
source share