ios - IOS/Objective-C:在 SLComposer 消息后关闭视图控制器
问题描述
在 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。
在此先感谢您的任何建议。
解决方案
您的视图控制器当前正在呈现SLComposeViewController
.
因此,当您调用dismissViewControllerAnimated:completion:
时self
,您实际上是在要求解除SLComposeViewController
(已经在被解除的过程中)。
尝试要求presentingViewController
解雇代替:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
推荐阅读
- javascript - 为什么数组在响应中总是空的?
- css - css - 将全宽块定位在居中页面后面
- javascript - PrimeNG p-table 可滚动 scrollHeight 最后一行 p-dropdown 向上打开
- c# - 为什么 ReSharper 不建议对这两个块使用空传播?
- python - 在 Python 中将字符串转换为二维数组
- azure-active-directory - Azure AD - 不同租户中的主要帐户和来宾帐户之间的链接
- powershell - 为什么 Invoke-Command 在某些系统上不起作用?
- android - Android.Webkit.WebView 未在 Xamarin.Android 中加载 url
- github - 在 github 中将文件从一个帐户推送到另一个帐户
- spring-boot - @PathVariable 在 RequestMapping URL 中间带有斜杠