Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to do something when user segues back in a navigation controller(iOS)

I have a table view here and want to update the UI when user hit the 'back' button in a navigation controller. How can I do that?

like image 290
yoyosir Avatar asked May 04 '12 12:05

yoyosir


People also ask

What is unwind segue IOS?

Unlike the segues that you use to present view controllers, an unwind segue promises the dismissal of the current view controller without promising a specific target for the resulting transition. Instead, UIKit determines the target of an unwind segue programmatically at runtime.

How do I segue to another view controller?

Well, in addition to that, Ctrl+dragging also helps set up segues. So, Ctrl+Drag from the “Go to Other View Controller” button, to somewhere in the second View Controller. It can be anywhere in the main box of the second view controller. When you release, it will show you a box like the one below.


2 Answers

There are lots of avenues to accomplish something like this.

  • Implement viewWillDisappear
  • Implement viewWillAppear
  • Set up a delegate for your navigation and respond to changes
  • Make your own back button that links to your own function
  • Use an NSNotification when moving back

Anyone of the above is a good starting place.

like image 117
Dancreek Avatar answered Nov 08 '22 04:11

Dancreek


Providing a code with your question would help us to help you !

Have you tried something like this ?

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[self tableView] reloadData];
}
like image 25
Haris Avatar answered Nov 08 '22 03:11

Haris