ios - View Controller Presentation Warning - 同时呈现两个

标签 ios uiviewcontroller uikit

当我尝试以模态方式呈现第二个 VC 时收到此警告。

Warning: Attempt to present <RCTAddCardViewController: 0x1f5b21e0> on <IRSlidingSplitViewController: 0x1f538140> while a presentation is in progress!

这是我的做法:

UIViewController *pvc = [self presentingViewController];
[self dismissViewControllerAnimated:YES completion:^{
    RCTAddCardViewController *vc = [[RCTAddCardViewController alloc] initWithNibName:nil bundle:nil];
    [pvc presentViewController:vc animated:YES completion:nil];
}];

我不应该收到错误,因为它出现在第一个 VC 解雇的完成处理程序中。任何人都知道让这个消失的方法吗?

最佳答案

由于您在 self 上调用 -dismissViewControllerAnimated:,如果您还通过 self 呈现 View Controller ,则该 View Controller 将被解雇(因此 pvc 仍将呈现 self)。如果这不是问题,我想它只会在完成 block 返回后才算完成演示。

一种解决方法是创建一个 -myPresentViewController: 方法,然后使用 use

[self performSelector:@selector(presentViewController:) withObject:vc afterDelay:0.001]

block 内

关于ios - View Controller Presentation Warning - 同时呈现两个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15868816/

相关文章:

ios - 如何从关闭命令访问以前的 View Controller

xcode - 使用 Storyboard或以编程方式创建 View 时自定义初始化

IOS UINavigationController、pushViewController 不工作

ios - Swift 中的 NSDictionary :Cannot subscript a value of type 'AnyObject?' with a index of type 'Int'

ios - 如何为自定义 UIWindow 实现我自己的 getter 方法?

ios - 以编程方式添加前导/顶部约束

ios - 如何在 iOS 7 上将状态栏内容颜色设置为白色

iphone - 带有自定义layoutSubviews的UIScrollView不再有动画

ios - UIPickerView 为空

ios - UICollectionView:选择时动画单元格大小变化