4

我曾尝试使用 SLComposeViewController 在 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 中,这张表出现在我在窗口中添加的视图后面。我该如何解决这个问题?在此处输入图像描述

4

3 回答 3

1

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

于 2014-10-11T11:23:45.970 回答
0
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];

        });
于 2015-01-19T07:49:25.093 回答
0
UINavigationController *forShare = [[UINavigationController alloc] initWithRootViewController:vc];
[forShare setNavigationBarHidden:YES];
[self presentViewController:forShare animated:NO completion:nil];

如果动画:是,它不起作用如果动画:否,它对我有用

于 2014-10-29T14:01:45.513 回答