当我试图发布到Twitter时,它会显示一条错误消息,上面写着"无法发送推文,因为与Twitter的连接失败"
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
if (composeViewController)
{
NSString *initialTextString = @"Test";
[composeViewController setInitialText:initialTextString];
[composeViewController setCompletionHandler:^(SLComposeViewControllerResult result)
{
if (result == SLComposeViewControllerResultDone)
{
NSLog(@"Posted");
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"" message:@"Posted on Twitter" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alert1 show];
[self performSelector:@selector(dismiss:) withObject:alert1 afterDelay:1.0];
}
else if (result == SLComposeViewControllerResultCancelled)
{
NSLog(@"Post Cancelled");
}
else
{
NSLog(@"Post Failed");
}
}];
[self presentViewController:composeViewController animated:YES completion:nil];
}
}