** Я добавил Twitter.framework и Accounts.framework.
И импортировал заголовочный файл Twitter.h.
Но я получаю сообщение об ошибке "Использование необъявленного идентификатора 'tweetSheet'" **
Class TWTweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController");
if(TWTweetComposeViewController != nil) {
//For iOS 5.0 onwards
if ([TWTweetComposeViewController canSendTweet]) {
//Create the tweet sheet
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
//Customize the tweet sheet here
//Add a tweet message
[tweetSheet setInitialText:[[self getShareContent] objectForKey:@"twitterContent"]];
//Set a blocking handler for the tweet sheet
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){
if (TWTweetComposeViewControllerResultDone) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Tweeted"
message:@"You successfully tweeted"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
} else if (TWTweetComposeViewControllerResultCancelled) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Ooops..."
message:@"Something went wrong, try again later"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
[self dismissModalViewControllerAnimated:YES];
};
//Show the tweet sheet!
[self presentModalViewController:tweetSheet animated:YES];
} else {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
message:@"You need to configure your Twitter account in the Settings"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}