Reputation: 3240
I have an application with one UILabel
and one UIButton
.
How can I send the text in the UILabel
to Twitter?
Upvotes: 0
Views: 588
Reputation: 960
Here is the simple code that all you need:
-(IBAction)postTwitter:(id)sender {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:yourlabel.text];
[self presentViewController:tweetSheet animated:YES completion:nil]; }
Upvotes: 0
Reputation: 2493
in iOs 5 it is very simple.
first add the twitter framework der Build Phases / Link Binary With Libraries
- (IBAction)yourTweetUIButtonAction:(id)sender {
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweet =
[[TWTweetComposeViewController alloc] init];
[tweet setInitialText:yourUILabel.text];
[self presentModalViewController:tweet animated:YES];
} else {
//can't tweet!
}
...
Upvotes: 2