Find out if user pressed the back button in uinavigationcontroller?

后端 未结 7 1637
时光说笑
时光说笑 2020-12-01 03:34

When a view loads, i want to see if it\'s because the user pressed the back button. How can i check this?

7条回答
  •  暖寄归人
    2020-12-01 04:10

    For the sake of completeness, mix of two most upvoted answers (1, 2) in Swift:

    override func willMoveToParentViewController(parent: UIViewController?) {
        super.willMoveToParentViewController(parent)
        if parent == nil {
            // view controller is popping
        }
    }
    

提交回复
热议问题