facebook - Objective C - SLComposeViewController delayed presention -


i've been doing program takes care of posting picture or words (or both) both facebook , twitter. want them both @ same time, wrote code this:

//post facebook if ([slcomposeviewcontroller isavailableforservicetype:slservicetypefacebook]) {         slcvc = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypefacebook];         [slcvc addimage:bim];         [slcvc setinitialtext:tf.text];         [self presentviewcontroller:slcvc animated:yes completion:null];     }     else {         uialertview *alert = [[uialertview alloc] initwithtitle:@"facebook - not logged in!" message:@"you need login (or sign up) post..." delegate:nil cancelbuttontitle:@"too bad!" otherbuttontitles:nil];         [alert show];     }  //post twitter if ([slcomposeviewcontroller isavailableforservicetype:slservicetypetwitter]) {         slcvc = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter];         [slcvc addimage:bim];         [slcvc setinitialtext:tf.text];         [self presentviewcontroller:slcvc animated:yes completion:null];     }     else {         uialertview *alert = [[uialertview alloc] initwithtitle:@"twitter - not logged in!" message:@"you need login (or sign up) post..." delegate:nil cancelbuttontitle:@"too bad!" otherbuttontitles:nil];         [alert show];     } 

this of course, in ibaction function "file owned" (slcvc slcomposeviewcontroller, bim uiimage, , tf.text text of uitextfield tf). , have posted code before, worked separately. if try use post picture facebook , twitter @ same time, error:

attempt present <sltwittercomposeviewcontroller: 0xf6265e0> on <viewcontroller: 0x9476960> waiting delayed presention of <slfacebookcomposeviewcontroller: 0x9432d70> complete 

(i'm still allowed post facebook not twitter)

i'm sure happens because slcomposeviewcontroller registers free operate again once first posting (the 1 facebook in case) done. there way have second posting (the 1 twitter) wait somehow user send first posting (to facebook) , present posting twitter? in advance or suggestions!!

you need use completion handler of slcomposeviewcontroller. called after user done composing post or cancelling it:

[slcvc setcompletionhandler:^(slcomposeviewcontrollerresult result) {     //post twitter     if ([slcomposeviewcontroller isavailableforservicetype:slservicetypetwitter]) {         slcvc2 = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter];         [slcvc2 addimage:bim];         [slcvc2 setinitialtext:tf.text];         [self presentviewcontroller:slcvc animated:yes completion:null];     }     else {         uialertview *alert = [[uialertview alloc] initwithtitle:@"twitter - not logged in!" message:@"you need login (or sign up) post..." delegate:nil cancelbuttontitle:@"too bad!" otherbuttontitles:nil];         [alert show];     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -