1

I have simple question. I using storyboard with Navigation Controller. Application performs a push segue from first VC to another. After user press a "Back" button, he will return, to first VC. I need to handle this event, to refresh display data.

How can I do it?

Thanks.

Andrey
  • 2,659
  • 4
  • 29
  • 54

4 Answers4

2

I hope you need to refresh the data in first VC. Implement viewDidAppear: in first VC

-(void)viewDidAppear:(BOOL)animated
{
  [super viewDidAppear:animated];
  // refresh data
}
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
0

Give a look at this question: back button callback in navigationController in iOS

-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
   // back button was pressed.  We know this is true because self is no longer
   // in the navigation stack.  
}
[super viewWillDisappear:animated];
}
Community
  • 1
  • 1
0

In pre iOs 5.0 you can use -viewWillDisappear:

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    if (![[self.navigationController viewControllers] containsObject:self]) {
        //...
    }
}

in iOS 5.0+ you can use -didMoveToParentViewController:

- (void)didMoveToParentViewController:(UIViewController *)parent
{
    //...
}
pchelnikov
  • 425
  • 6
  • 6
0
- (void)didMoveToParentViewController:(UIViewController *)parent{
    if(!parent){
        //...
    }
}
Masatsugu Hosoi
  • 420
  • 6
  • 7