Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Created April 9, 2018 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takashi1975/59d7065fb13d6fe68dfb69d38915bb30 to your computer and use it in GitHub Desktop.
Save takashi1975/59d7065fb13d6fe68dfb69d38915bb30 to your computer and use it in GitHub Desktop.
override func viewWillDisappear(_ animated: Bool) {
/**
* UINavigationControllerの戻る[back]処理のイベントを取得する方法
* https://qiita.com/syamaoka/items/509ff50fcab485347600
* ... viewWillDisappearが呼ばれる時に、戻る処理を行っていれば、NavigationControllerのviewControllersの中にselfは存在していない
*/
if let viewControllers = self.navigationController?.viewControllers {
let existsSelfInViewControllers = viewControllers.filter{$0 == self}.count == 0
if existsSelfInViewControllers {
Logger.log(message: "Test")
}
}
}
@takashi1975
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment