我一直在使用这个代码来发布推特。
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 帐户,则会显示具有设置和取消按钮的警报。但它没有在设备中显示警报?任何人都可以帮助我吗?提前致谢 。
Facebook 共享也会发生同样的情况。删除测试:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
如果用户的 Twitter 帐户尚未在 iOS 6 中设置,则上述测试将评估为 false,并且不会执行任何共享代码。
相反,如果您跳过检查并尝试出示SLComposeViewController无论如何,iOS 都会提示用户设置他们的 Twitter 帐户。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)