IOS/objective-C : Dismiss view controller after SLComposer message

标签 ios objective-c slcomposeviewcontroller

我正在尝试在 SLComposer 发送消息后关闭 View Controller 。

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

  [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];
}

然而,尽管我将解雇放在完成 block 中,它在 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 没有委托(delegate),所以想知道如何确定它实际上已被解雇,以便我可以解雇它下面的下一个 VC。

提前感谢您的任何建议。

最佳答案

您的 View Controller 当前正在呈现SLComposeViewController

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

尝试让 presentingViewController 关闭:

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

关于IOS/objective-C : Dismiss view controller after SLComposer message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52068122/

相关文章:

ios - Xcode 8 - 找不到框架 -sqlite3

ios - SLComposeViewController 不正确的结果

ios - SLComposeViewController Facebook 发布为 iOS 而不是 Facebook 应用程序标识符

android - StatefulWidget的createState方法中如何读取值

ios - 如何在应用关闭时用户单击通知时获取用户信息?

ios - 在更改 VC 之前获取并存储 PanoramaView 的位置

javascript - 使用 Parse Cloud 代码模块通过 SendGrid 发送附件

objective-c - ObjCMongoDB 坏了?我无法让它工作

ios - 如何在 iOS 上使用 BLE(低功耗蓝牙)从人体秤获取数据作为 CBPeripheral

ios - 带有屏幕截图但没有图像附件的 SLComposeViewController