On my mainVC I have a TableView with a button that should open the secondVC, where I can add things to show then in the Table, with the kind: "Present As Popover".
I'm opening the secondVC with performSegue(withIdentifier:"goToOtherView", sender: nil
.
class FirstViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var groupData = ["Data, Data1, Data2"]
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .green
tableView.delegate = self
tableView.dataSource = self
}
@IBAction func btnTapped(_ sender: Any) {
performSegue(withIdentifier: "goToOtherView", sender: nil)
}
override func viewWillAppear(_ animated: Bool) {
print("FirstViewController will appear")
}
override func viewDidAppear(_ animated: Bool) {
print("FirstViewController did appear")
}
override func viewWillDisappear(_ animated: Bool) {
print("FirstViewController will disappear")
}
override func viewDidDisappear(_ animated: Bool) {
print("FirstViewController did disappear")
}
}
class SecondViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .blue
}
override func viewWillAppear(_ animated: Bool) {
print("SecoundViewController will appear")
}
override func viewDidAppear(_ animated: Bool) {
print("SecoundViewController did appear")
}
override func viewWillDisappear(_ animated: Bool) {
print("SecoundViewController will disappear")
}
override func viewDidDisappear(_ animated: Bool) {
print("SecoundViewController did disappear")
}
}
The FirstViewController willDisappear
and didDisappear
are never being called, or even when the secondVC is closed the willAppear
and didAppear
. I want to call the function tableView.reloadData()
when the FirstView willAppear
/didAppear
It's kinda the same like the IOS default clock app, when you add a new alarm clock.
Quick guess, but I think that’s because of the presentation mode being pageSheet
Can you try to change it to fullScreen?
You can also change your segue configuration to be like:
View disappear won't be called since the view does not completely disappears from the window