Just add the Twitter framework in build phases.
- (IBAction)twitterShare:(id)sender {
NSLog(@"Twitter ");
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:@"This is the message that will be tweeted!"];
//[twitter addImage:[UIImage imageNamed:@"image_No.jpeg"]];
// [twitter addImage:img.image];
[self presentViewController:twitter animated:YES completion:nil];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
if(res == TWTweetComposeViewControllerResultDone) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"The Tweet was posted successfully." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
[alert show];
}
if(res == TWTweetComposeViewControllerResultCancelled) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Cancelled" message:@"You Cancelled posting the Tweet." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
[alert show];
}
[self dismissModalViewControllerAnimated:YES];
};
}
No comments:
Post a Comment