提出新的视图控制器后关闭当前视图控制器-迅速 [英] dismiss current view controller AFTER presenting new view controller - swift

查看:54
本文介绍了提出新的视图控制器后关闭当前视图控制器-迅速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图解散一个VC,并提出一个新的VC.但我不希望再有旧的VC.我使用下面的代码关闭当前的VC并提出新的VC.但是这样一来,解雇与出席之间会有一定的时间间隔.我不希望用户注意到这一点.因此,我想先展示新的VC,然后关闭上一个.有什么办法吗?

I'm trying to dismiss a VC and present a new VC. but I don't want old VC to exist anymore. I use the code below to dismiss current VC and present new one. but this way, there's a time interval between dismiss and present. I don't want the user to notice this. so, I want to present new VC first and then dismiss previous one. Is there any way to do this?

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationController = self.storyboard?.instantiateViewController(withIdentifier: "login") as! Login
let presentingVC = self.presentingViewController
self.dismiss(animated: false, completion: { () -> Void   in
    presentingVC!.present(destinationController, animated: true, completion: nil)
})

推荐答案

我认为最好的方法是在实际返回时关闭当前的VC.这意味着,使用当前的VC显示 destinationController ,然后返回时,关闭两个VC

I think the best way will be to dismiss the current VC when you actually go back. That means, present your destinationController using the current VC and then when you go back, dismiss both VC's

这篇关于提出新的视图控制器后关闭当前视图控制器-迅速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆