gpt4 book ai didi

ios - 关闭当前的 UIViewcontroller 并呈现一个新的 UiViewController

转载 作者:搜寻专家 更新时间:2023-10-31 19:33:59 25 4
gpt4 key购买 nike

我打算关闭当前的 UIViewController 并呈现给新的 UIViewController

我使用了下面的代码

 let newViewController: ViewController = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController") as! ViewController
self.presentViewController(newViewController, animated: false, completion: {
self.dismissViewControllerAnimated(false, completion: nil)
})

报错如下

2016-06-04 11:40:59.864 myApp[851:117649] Trying to dismiss the
presentation controller while transitioning already. (<_UIFullscreenPresentationController: 0x1703e6900>) 2016-06-04 11:40:59.878 ePassBook[851:117649] transitionViewForCurrentTransition is not set, presentation controller was dismissed during the presentation? (<_UIFullscreenPresentationController: 0x1703e6900>)

最佳答案

使用此代码,

Objective-C 代码:

[self.navigationController presentViewController:newViewController animated:NO completion:^{
dispatch_after(0, dispatch_get_main_queue(), ^{
[self.navigationController dismissViewControllerAnimated:NO completion:nil];
});
}];

快速代码:

self.navigationController?.presentViewController(newViewController, animated: false, completion: { () -> Void in
dispatch_after(0, dispatch_get_main_queue(), { () -> Void in
self.navigationController?.dismissViewControllerAnimated(false, completion: nil)

})
})

希望对你有帮助

关于ios - 关闭当前的 UIViewcontroller 并呈现一个新的 UiViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37627039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com