Pages

Friday, 5 December 2014

How to share text and image and URL on Twitter in iOS



1]Import  Social  and  Account Framework  in  project


2] Import in code as well
#import <Social/Social.h>#import <Accounts/Accounts.h>



3]Add the following code and declare method and set refranceing to button 



-(IBAction)twitterPost:(id)sender

{
    SLComposeViewController *tweetSheet = [SLComposeViewController 
    composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:@“Hey Hi , My First Tweeet ”];
    [tweetSheet addImage:[UIImage imageNamed:@"arjun.png"]];    [tweetSheet addURL:[NSURL URLWithString:@"http://xcodar.blogspot.in"]];
    [self presentModalViewController:tweetSheet animated:YES];
}


Its very easy to share the text , image and url on twitter  

-Arjun Taval

No comments:

Post a Comment