Hi I have two UIButtons in an iOS app. One of them is to post to twitter, the second is to post to Facebook. The facebook button works fine, but the tweet code bypasses me with some problems, the tweet list will open with the text filled in, however, to cancel, two clicks of the cancel button are required. If I click on submit, the tweet will be sent and the sheet will be rejected, but my application will freeze and stop responding. I turned on both bits of code
- (IBAction)postTweet:(id)sender { // if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]){ myTweet = [[SLComposeViewController alloc]init]; myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; NSString *tweetString = [[NSString alloc]initWithFormat:@"%@\n%@\nvia @ValuatorApp", pdOne.text, pdTwo.text]; [myTweet setInitialText:tweetString]; [myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]]; [self presentViewController:myTweet animated:YES completion:nil]; // } [myTweet setCompletionHandler:^(SLComposeViewControllerResult result) { NSString *output = [[NSString alloc]init]; switch (result) { case SLComposeViewControllerResultCancelled: output = @"Twitter Post Cancelled"; break; case SLComposeViewControllerResultDone: output = @"Twitter post Succesful"; break; default: break; } NSLog(@"%@",output); }]; } - (IBAction)postFacebook:(id)sender { // if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){ myTweet = [[SLComposeViewController alloc]init]; myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; if (pd3 != 0) { NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n%@", pdOne.text,pdTwo.text, pdThree.text]; [myTweet setInitialText:facebookString]; } else if (pd3 == 0){ NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n", pdOne.text,pdTwo.text]; [myTweet setInitialText:facebookString]; } // [myTweet addImage:[UIImage imageNamed:@"Photo Jun 02, 22 46 37.jpg"]]; [myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]]; [self presentViewController:myTweet animated:YES completion:nil]; // } [myTweet setCompletionHandler:^(SLComposeViewControllerResult result) { NSString *output = [[NSString alloc]init]; switch (result) { case SLComposeViewControllerResultCancelled: output = @"Facebook Post Cancelled"; break; case SLComposeViewControllerResultDone: output = @"Facebook post Succesful"; break; default: break; } NSLog(@"%@",output); }]; }
sjbuchanan007
source share