通过SLComposeViewController发布在IOS和8的Facebook和Twitter上

问题描述:

我试图使用SLComposeViewController发布在facebook和twitter上。我的代码是通过SLComposeViewController发布在IOS和8的Facebook和Twitter上

-(void)postToFacebookWithObject:(id)object FromController:(UIViewController*)vc { 

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) 
    { 
    SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
    SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ 
     if (result == SLComposeViewControllerResultCancelled) 
     { 
      DLog(@"Cancelled"); 

     } 
     else 
     { 
      DLog(@"Done"); 
     } 
     [controller dismissViewControllerAnimated:YES completion:Nil]; 
    }; 
    controller.completionHandler =myBlock; 
    [controller removeAllImages]; 
    [controller removeAllURLs]; 
    NSMutableDictionary *item = (NSMutableDictionary *)object; 
    [controller setInitialText:[item objectForKey:@"DealTitle"]]; 
    if([item objectForKey:@"DealImage"]) 
     [controller addImage:[item objectForKey:@"DealImage"]]; 
    if([item objectForKey:@"url"]) 
    [controller addURL:[NSURL URLWithString:[item objectForKey:@"url"]]]; 

    [vc presentViewController:controller animated:YES completion:Nil]; 
} 
else 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:LocStr(@"NO_FACEBOOK_ACCOUNT_CONFIGURED") delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
    [alert show]; 
    DLog(@"UnAvailable"); 
} 

}

这在IOS 7但在IOS 8此片来后面我认为这是我的窗口加入工作正常。我如何解决这个问题? enter image description here

+0

请升级iOS8上Facebook的SDK。 – iDeveloper 2014-10-01 06:11:01

+0

使用Apples Social.framework时,Facebook SDK不是必需的,那么您如何期待升级SDK将解决问题? – 2014-10-10 20:57:07

+0

@KyleBegeman我仍然面对这一个。任何方式摆脱这个问题? – 2014-10-11 07:33:37

我已经通过在navigationcontroller.view上添加我的视图而不是在窗口上解决了这个问题。

UINavigationController *forShare = [[UINavigationController alloc] initWithRootViewController:vc]; 
[forShare setNavigationBarHidden:YES]; 
[self presentViewController:forShare animated:NO completion:nil]; 

如果动画:是它不工作 如果动画:不,它为我的作品

+0

这是一个答案或问题,你有同样的问题? – EWit 2014-10-29 14:08:32

I have resolved through open present-view controller in navigation-bar.it may help you. 

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
     [controller setInitialText:shareFrom]; 
     [controller addImage:self.photoImageView.image]; 
     [controller addURL:[NSURL URLWithString:dayCareWebsite]]; 
     dispatch_async(dispatch_get_main_queue(),^{ 

      [self.navigationController presentViewController:controller animated:YES completion:nil]; 

     });