1

我试图SLServiceTypeFacebook在关闭视图控制器后呈现视图控制器 ()。像这样

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

    ////////////////////////////////////
    //Some Stuff Other Calculations//
    ////////////////////////////////////
    //Then

    if([SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook])
    {
        // Facebook Service Type is Available

        SLComposeViewController *slVC   =   [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
        SLComposeViewControllerCompletionHandler handler    =   ^(SLComposeViewControllerResult result)
        {
            if (result == SLComposeViewControllerResultCancelled)
            {
                NSLog(@"Cancelled");

            }
            else
            {
                NSLog(@"Done");
            }

            [slVC dismissViewControllerAnimated:NO completion:Nil];
        };
        slVC.completionHandler = handler;
        [slVC setInitialText:post[@"user_fullname"]];
        [slVC addURL:[NSURL URLWithString:post[@"url"]]];

        [self presentViewController:slVC animated:NO completion:Nil];
    }

但这似乎不起作用。Facebook 模态会自动取消。

我在概念上做错了吗?

4

2 回答 2

5

像这样使用完成块:

[self dismissViewControllerAnimated:NO completion:^{

   //SHOW YOUR NEW VIEW CONTROLLER HERE!
}];

您缺少上面的完成处理程序。

于 2013-05-27T08:17:48.670 回答
0

尝试这个:

[self dismissViewControllerAnimated:NO completion:^{
    NewViewController *viewController = [[NewViewController alloc]initWithNibName:NSStringFromClass([NewViewController class]) bundle:nil];
    UIViewController *topRootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
    while (topRootViewController.presentedViewController)
    {
        topRootViewController = topRootViewController.presentedViewController;
    }

    [topRootViewController presentViewController:viewController animated:YES completion:nil];
}];
于 2019-07-12T11:58:24.023 回答