dismiss current view controller AFTER presenting new view controller - swift

后端 未结 4 2541
一整个雨季
一整个雨季 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条回答
  •  灰色年华
    2021-02-19 10:55

    The way I do it is to use both

    view.dismiss(animated: true, completion: nil)
    

    and

    presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)
    

    depend on how many view controllers before. Because they are all optional, Xcode will not complain if you don't have them when you are trying to dismiss. If that is the case, the single dismiss() function will work just fine.

    I guess it is because I didn't have a good design in the first place, it works but I don't think you will run into this if you have a good structure in the first place.

提交回复
热议问题