# How to detect when the "Back" button is clicked in a UINavigationController

**URL:** <https://forums.kodeco.com/t/how-to-detect-when-the-back-button-is-clicked-in-a-uinavigationcontroller/23898>\
**Category:** iOS\
**Created:** [December 8, 2016, 5:21pm UTC](https://forums.kodeco.com/t/how-to-detect-when-the-back-button-is-clicked-in-a-uinavigationcontroller/23898 "2016-12-08T17:21:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfortyork](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jfortyork/32/81494_2.png) [@jfortyork](https://forums.kodeco.com/u/jfortyork)\
**Post date:** [December 8, 2016, 5:21pm UTC](https://forums.kodeco.com/t/how-to-detect-when-the-back-button-is-clicked-in-a-uinavigationcontroller/23898/1 "2016-12-08T17:21:40Z")

</div>

Hello All,

I have an app that has 2 screens in it. When a button is clicked on the first screen, the UINavigationController pushes the next view controller onto the stack. When I click the “Back” button on the 2nd view controller, I want to pass some information back to the 1st view controller.

The problem is that I don’t know how to detect that the “Back” button was selected on the 2nd view controller.

How do I accomplish this?

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![aeberbach](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aeberbach/32/81494_2.png) [@aeberbach](https://forums.kodeco.com/u/aeberbach)\
**Post date:** [December 9, 2016, 3:21am UTC](https://forums.kodeco.com/t/how-to-detect-when-the-back-button-is-clicked-in-a-uinavigationcontroller/23898/2 "2016-12-09T03:21:15Z")

</div>

You can receive a call from the Navigation Controller -

`func navigationController(UINavigationController, willShow: UIViewController, animated: Bool)`

if you set the object where you want to take the action as delegate. If `willShow` is the view controller whose information you need to update then you know you are going back to it.
