dismiss current view controller AFTER presenting new view controller - swift

后端 未结 4 2521
一整个雨季
一整个雨季 2021-02-19 10:24

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\

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 10:44

    If you want to present VC B from VC A and want to dismiss VC A while Presenting, you can use this code:

    You write this code in your VC A from which Button you want to present the VC B.

    let parentVC = presentingViewController
    dismiss(animated: true) {
        let vc = self.storyboard!.instantiateViewController(withIdentifier...)
        parentVC.present(vc, animated: true)`enter code here`
    }
    

提交回复
热议问题