Kyl*_*loR 7 uiviewcontroller viewcontroller dismiss ios swift
所以我有一个视图控制器,我显示如下:
func showProfileForTrainer(trainer: Trainers) {
let viewPTProfileVC = ViewPTProfileVC()
viewPTProfileVC.trainer = trainer
self.navigationController?.pushViewController(viewPTProfileVC, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
但是当试图忽视这个观点时,我无法让它发挥作用.它在导航栏中有一个后退按钮,功能很好,但是当试图通过按钮关闭视图时,它什么都不做.我目前尝试过:
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)
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我尝试过各种各样的方法而且都没有工作,而控制台只是输出5
.
令人沮丧的是,在我的应用程序的其他地方,我以与开头所示相同的方式呈现了一个视图,并且它被解雇了 dismiss(animated: true) { ... }
知道为什么它不能在这里工作吗?
Pau*_*tos 33
您必须从相应的导航控制器弹出视图控制器:
self.navigationController?.popViewController(animated: true)
Run Code Online (Sandbox Code Playgroud)
小智 8
如果你正在使用pushviewcontroller method
那么dismiss
你必须使用popviewcontroller method
.
试试这个:
self.navigationController?.popViewController(animated: true)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8278 次 |
最近记录: |