viewController not being removed properly?

后端 未结 2 610
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 02:52

In my viewController I have an NSFetchedResultsController for populating a tableView. In the viewDidLoad() I\'m saving the current time to

2条回答
  •  走了就别回头了
    2021-01-29 03:15

    I'm leaving the view in a seperate function like this:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "HomePage") as? HomeVC
    controller?.managedObjectContext = self.managedObjectContext
    self.present(controller!, animated: true, completion: nil)
    

    Yup, that's the problem. Instead of returning to the existing HomeVC, you're making a new HomeVC and presenting that on top of yourself. So you just keep piling up the view controllers.

    What you need to do to get back home is unwind what you did to get here. If present, now dismiss. If push, now pop.

提交回复
热议问题