我创建了一个使用以下内容的应用程序:
SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter
代码似乎可以正常工作,并将帖子发布到 Facebook 和 Twitter,但是一旦帖子完成,我返回应用程序视图,没有任何控件处于活动状态,我必须关闭应用程序并重新启动它们才能再次工作.
我想我在 IF 语句(下面发布)中嵌套了错误的代码,所以想知道是否有人可以提供任何建议。
我对 Xcode 等非常陌生,所以请耐心等待我 :-)
提前致谢
皮特
- (IBAction)postButton:(id)sender
{ if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *facebook = [[SLComposeViewController alloc] init];
([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]);
{
SLComposeViewController *twitter = [[SLComposeViewController alloc] init];
facebook = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebook setInitialText:[[self statusMessage]text]];
twitter = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[twitter setInitialText:[[self statusMessage]text]];
[self presentViewController:facebook animated:YES completion:nil];
[facebook setCompletionHandler:^(SLComposeViewControllerResult result)
{
NSString *output;
switch (result)
{
case SLComposeViewControllerResultCancelled:
output = @"Action Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Post Sucessfull";
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[self presentViewController:twitter animated:YES completion:nil];
[twitter setCompletionHandler:^(SLComposeViewControllerResult result)
{
NSString *output;
switch (result)
{
case SLComposeViewControllerResultCancelled:
output = @"Action Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Tweet Sucessfull";
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Twitter" message:output delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}];
}
];}
}
}