我想在 facebook 上分享一个帖子,当我使用 iOS 6 时它可以正常工作,但在 iOS 5 和 iOS 5.1 中,它会出现登录问题,当我登录并转到已经授权的页面并按 OK 按钮时,它会将我拉回登录,就像这并在这两页上一次又一次地重复
当我按下确定时,它会回馈
case 1: // facebook
{
if(NSClassFromString(@"SLComposeViewController"))
{
SLComposeViewController *fbController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[fbController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
ALERT_VIEW(@"Successfully posted to facebook.");
}
break;
}};
[fbController setInitialText:quotesss];
[fbController setCompletionHandler:completionHandler];
[self presentViewController:fbController animated:YES completion:nil];
}
else
{
DEFacebookComposeViewControllerCompletionHandler completionHandler = ^(DEFacebookComposeViewControllerResult result) {
switch (result) {
case DEFacebookComposeViewControllerResultCancelled:
NSLog(@"Facebook Result: Cancelled");
break;
case DEFacebookComposeViewControllerResultDone:
ALERT_VIEW(@"Successfully posted to facebook.");
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
};
DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[facebookViewComposer setInitialText:quotesss];
facebookViewComposer.completionHandler = completionHandler;
[self presentViewController:facebookViewComposer animated:YES completion:nil];
[facebookViewComposer release];
}
break;
}
case 2: // twitter
{
NSString *text = [NSString stringWithFormat:@"%@", quotesss ];
if([text length] > 135)
{
text = [NSString stringWithFormat:@"%@%@", quotesss ,@"..."];
text = [text substringToIndex:135];
}
if(NSClassFromString(@"SLComposeViewController"))
{
SLComposeViewController *twitterController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[twitterController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
ALERT_VIEW(@"Successfully posted to twitter.");
}
break;
}};
[twitterController setInitialText:text];
[twitterController setCompletionHandler:completionHandler];
[self presentViewController:twitterController animated:YES completion:nil];
}
else
{
DETweetComposeViewControllerCompletionHandler completionHandler = ^(DETweetComposeViewControllerResult result) {
switch (result) {
case DETweetComposeViewControllerResultCancelled:
NSLog(@"Twitter Result: Cancelled");
break;
case DETweetComposeViewControllerResultDone:
ALERT_VIEW(@"Successfully posted to twitter.");
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
};
DETweetComposeViewController *tcvc = [[[DETweetComposeViewController alloc] init] autorelease];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[tcvc setInitialText:quotesss];
tcvc.completionHandler = completionHandler;
[self presentViewController:tcvc animated:YES completion:nil];
}
break;
}