Tag Archives: Twitter

TWTweetComposeViewController doesn’t display initial tweet

TWTweetComposeViewController doesn’t display tweets, that are too long. You can take a substring of a tweet by cutting down to 140 symbols:

Apple’s Twitter framework example

This is an example, how to integrate Twitter framework of Apple to your app.

Firstly, add Twitter (Twitter.framework) and MobileCoreServices frameworks to your app.

Then add header files to your source file:


Then add this method or similar:

- (void)sendToTwitter {
if ([appDelegate iOSVersion5]) {
[self showErrorAlert:@"Отправка в Twitter доступна только в iOS 5 и выше."];
tweetView = [[TWTweetComposeViewController alloc] init];
completionHandler =
^(TWTweetComposeViewControllerResult result) {
switch (result)
case TWTweetComposeViewControllerResultCancelled: {
NSLog(@"Twitter Result: canceled");
[self showErrorAlert:@"Отправка в Twitter отменена."];
case TWTweetComposeViewControllerResultDone: {
NSLog(@"Twitter Result: sent");
[self showErrorAlert:@"Отправка в Twitter выполнена."];
default: {
NSLog(@"Twitter Result: default");
[self showErrorAlert:@"Отправка в Twitter не выполнена."];
[self dismissModalViewControllerAnimated:YES];
[tweetView setCompletionHandler:completionHandler];
[tweetView setInitialText:self.textToExport];
[self presentModalViewController:tweetView animated:YES];

Here, firstly iOS version is checked, because it will work only in iOS 5 or later. Then, I create TWTweetComposeViewController instance, it’s block completion handler, set text to export to Twitter and then present controller as a modal controller.