我想在解雇停留viewWillAppear
后致电ViewController
。
ViewController1
- > Segue
- > ViewController2
在VeiwController2中
1)
self.dismiss(animated: true, completion: nil)
2)。
override func viewDidDisappear(_ animated: Bool) {
ViewController1().viewWillAppear(true)
}
在VeiwController1
调用viewWillAppear
时,我的应用程序出现null
错误。如何解雇overContext
ViewController
并以正确的方式调用viewWillAppear
方法。
答案 0 :(得分:5)
ViewController1().viewWillAppear(true)
尝试删除:
VC1中的 super.viewWillAppear(animated)
。
viewDidAppear not getting called
它甚至会回到你的VC吗? self.dismiss在这里使用“Present Modally”segue。或者使用popViewController
嵌入NavigationBar答案 1 :(得分:1)
yout模态应为.fullScreen
尝试一下:
let createAccounts = CreateAccounts();
let navController = UINavigationController(rootViewController: createAccounts)
navController.modalPresentationStyle = .fullScreen
答案 2 :(得分:0)
// Override this function in ViewController1
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
//Your code here will execute after viewDidLoad() or when you dismiss the child viewController
}
我建议你完成ViewController的生命周期。 Apple documentation for ViewController life cycle