iphone - Posting an image from a file instead to Facebook? -


how go posting image file instead facebook? works fine:

slcomposeviewcontroller *controllerslc = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypefacebook]; [controllerslc setinitialtext:@" iphone app"]; [controllerslc addurl:[nsurl urlwithstring:@"http://www.example.com"]];  [controllerslc addimage:[uiimage imagenamed:@"icon.png"]]; 

however i'm trying send image from:

 self.imageview.image = [self.photo objectforkey:photopicturekey]; 

try mate (ios6),

send image method,

make sure add social.framework , #import <social/social.h>

-(void) uploadtofacebook:(uiimage *) image{       if ([slcomposeviewcontroller isavailableforservicetype:slservicetypefacebook]){          slcomposeviewcontroller *fbcontroller =[slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypefacebook];         slcomposeviewcontrollercompletionhandler __block completionhandler=         ^(slcomposeviewcontrollerresult result){              [fbcontroller dismissviewcontrolleranimated:yes completion:nil];              switch(result){                 case slcomposeviewcontrollerresultcancelled:                 default:                 {                     nslog(@"cancelled.....");                 }                     break;                 case slcomposeviewcontrollerresultdone:                 {                     nslog(@"posted....");                     uialertview * alert = [[uialertview alloc] initwithtitle:@"sent" message:nil delegate:nil cancelbuttontitle:@"dismiss" otherbuttontitles: nil];                     [alert show];                 }                     break;             }};          [fbcontroller addimage:image];         [fbcontroller setinitialtext:@" iphone app"];         [fbcontroller addurl:[nsurl urlwithstring:@"http://www.example.com"]];          [fbcontroller setcompletionhandler:completionhandler];         [self presentviewcontroller:fbcontroller animated:yes completion:nil];     }     else{         uialertview *alertview = [[uialertview alloc] initwithtitle:@"sorry"                                                             message:@"you can't post on facebook right now, make sure device has internet connection , have @ least 1 facebook account setup"                                                            delegate:nil                                                   cancelbuttontitle:@"ok"                                                   otherbuttontitles:nil];         [alertview show];     } } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -