Search code examples
iosbuttonuinavigationcontrollerbackpressed

Custom action When Pressing 'back button' on a UINavigationController


I am using story boards to create my app, and I have a navigation controller which navigated back and forth between pages. Now when it goes back to a page (e.g. when the user taps the back button), I need the page which the user is going back to to refresh (or in another words to do the viewDidiLoad method again). Is there a way to configure the Navigation controller to the that? is there a way to call a method (ANY method - I don't car if it's a special method I have to create just for that purpose) when the 'back' button on the navigation controller is taped?

Thank you for your support!! Any help is very much appreciated =]


Solution

  • You can take actions in viewWillAppear or viewDidAppear but in general it is better to use a custom @protocol and the delegate pattern to communicate between 2 view controllers.