【问题标题】:IOS/Objective-C: Dismiss view controller after SLComposer messageIOS/Objective-C:在 SLComposer 消息后关闭视图控制器
【发布时间】:2018-08-29 01:04:14
【问题描述】:

我正在尝试在 SLComposer 发送消息后关闭视图控制器。

为此,我在 SLComposer 方法中使用了完成块,如下所示:

  [myPostSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

            switch (result) {


        case SLComposeViewControllerResultCancelled:
                NSLog(@"Post Canceled");
            [self alertPostFail];
                break;
            case SLComposeViewControllerResultDone:
                NSLog(@"Post Successful");
                success = 1;
                [self dismissUnderlyingVC ];

                break;

            default:
                break;
        }
    }];

-(void)dismissUnderlyingVC {
    LogDebug(@"trying to dismiss Underlying VC");
   [self dismissViewControllerAnimated:YES completion:nil];
}

但是,尽管我将解雇放在完成块中,但它在 SLComposer 实际被解雇之前被解雇,不会解雇下一个 VC 并给出以下错误:

     -[myVC dismissUnderlyingVC][Line 227] [DEBUG]
 trying to dismiss Underlying VC
    2018-08-28 20:23:59.579416-0400 idaru[1772:662392]
 [core] SLComposeViewController skipping explicit 
dismiss because isBeingDismissed is already 1
    2018-08-28 20:23:59.588142-0400 
idaru[1772:662392] [core] SLComposeViewController dealloc 

我知道 SLComposer 没有委托,所以想知道如何确定它实际上已被解雇,以便我可以解雇它下面的下一个 VC。

提前感谢您的任何建议。

【问题讨论】:

标签: ios objective-c slcomposeviewcontroller


【解决方案1】:

您的视图控制器当前正在呈现SLComposeViewController

因此,当您在 self 上调用 dismissViewControllerAnimated:completion: 时,您实际上是在要求关闭 SLComposeViewController(它已经在被关闭的过程中)。

尝试让presentingViewController 关闭:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 2012-05-19
    相关资源
    最近更新 更多