SLCOmviewviewcontroller微博分享警报问题

我一直在使用这个代码的Twitter发布。

SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){ [fbController dismissViewControllerAnimated:YES completion:nil]; switch(result){ case SLComposeViewControllerResultCancelled: default: { NSLog(@"Cancelled....."); } break; case SLComposeViewControllerResultDone: { NSLog(@"Posted...."); UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Posted Successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } break; }}; [fbController addImage:[UIImage imageNamed:@"1.jpg"]]; [fbController setInitialText:@"Check out this article."]; //[fbController addURL:[NSURL URLWithString:@"http://soulwithmobiletechnology.blogspot.com/"]]; [fbController setCompletionHandler:completionHandler]; [self presentViewController:fbController animated:YES completion:nil]; } 

如果用户没有设置Twitter帐户,则显示具有设置和取消button的警报。 但是它不显示设备中的警报? 请任何人帮助我。 提前致谢 。

Facebook共享也是一样。 删除testing:

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) 

如果用户的Twitter帐号尚未在iOS 6中设置,则上述testing将评估为false,并且不会执行任何共享代码。

相反,如果您跳过检查并尝试呈现SLComposeViewController ,则iOS将提示用户设置其Twitter帐户。

 BOOL canCompose= [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]; if (canCompose) { SLComposeViewController *fbCompose=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [fbCompose setInitialText:addressLabel.text]; [self presentViewController:fbCompose animated:YES completion:nil]; } 

一旦尝试这个代码,而不是使用completionHandler

按照这个教程。 这里打开警报。

http://www.appcoda.com/ios-programming-101-integrate-twitter-and-facebook-sharing-in-ios-6/

 - (IBAction)postToTwitter:(id)sender { if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [tweetSheet setInitialText:@"Great fun to learn iOS programming at appcoda.com!"]; [self presentViewController:tweetSheet animated:YES completion:nil]; }}