Reject pushed view controller

So, I have a view controller, which I show as follows:

func showProfileForTrainer(trainer: Trainers) {
    let viewPTProfileVC = ViewPTProfileVC()
    viewPTProfileVC.trainer = trainer
    self.navigationController?.pushViewController(viewPTProfileVC, animated: true)
}

But when I try to reject a view, I cannot get it to work. It has a back button on the navigation bar, which functions normally, but when you try to reject a view using the button, for example, it does nothing. I currently tried:

func handleMessageTrainer() {
    dismiss(animated: true) {
        print(1)
        self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
    }
    self.dismiss(animated: true) {
        print(2)
        self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
    }
    navigationController?.dismiss(animated: true, completion: {
        print(3)
        self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
    })
    self.navigationController?.dismiss(animated: true, completion: {
        print(4)
        self.tabBarVC?.showChatLogForTrainer(trainer: self.trainer!)
    })
    print(5)
}

As you can see, I tried different ways, and no one works, and the console displays 5.

Disappointingly, elsewhere in my application, I presented the view as shown at the beginning, and he rejected the penalty using dismiss(animated: true) { ... }

Any idea why it doesn't work here?

+4
2

:

self.navigationController?.popViewController(animated: true)
+12

pushviewcontroller method, dismiss, popviewcontroller method.

:

self.navigationController?.popViewController(animated: true)
+2

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


All Articles