Reject all current views

I am following a training video that teaches me about programmatically creating an iOS application without a storyboard.

Everything is going well and I like the most about it, however I have a little problem.

I am only halfway through, and I noticed a potential memory problem, as the tutorial showed me, for each next view I present it like this:

let ChooseCategoryController = ChooseCategoryViewController()
present(ChooseCategoryController, animated: true, completion: nil)

and then I present another view from it. And to go back, I also submit a different opinion. I noticed when starting the application that memory usage is increasing.

Is there a way when when presenting a new view, I can determine which views are open and close all the others?

I thought maybe something in the completion section, but I'm afraid, as I'm pretty new to it.

Thanks in advance.

Update1

. xcode , :

 dismiss(animated: false, completion: {
        self.present(DisplayQuestionsViewController(), animated: true, completion: nil)
    })

:

: < triviaGameApp.DisplayQuestionsViewController: 0x7fb39481ce00 > on < triviaGameApp.ChooseCategoryViewController: 0x7fb392e019f0 > !

. UICollectionView SelectCategoryViewController()

2:

:

dismiss(animated: false, completion: {
        self.parent?.present(DisplayQuestionsViewController(), animated: true, completion: nil)
    })

. , .

+4
1

, viewControllers windows . , .

. dismiss present .

dismiss(animated: false, completion: {
    self.parent?.present(MyOtherViewController(), animated: true, completion: nil
})

completion, , ViewController present MyOtherViewController .

+3

Source: https://habr.com/ru/post/1661855/


All Articles