0

I have a list of places with a right navigation bar item linking to a filter page. I want to set paramters on the filter page and push back to the placelist at the push of a button while taking the data with me and refreshing the previous view. I am currently doing this action when the button is pressed:

-(IBAction)save:(id)sender
{
    PlaceList *placelist = [[PlaceList alloc] initWithNibName:@"PlaceList" bundle:nil];
    placelist.searchTxt = self.searchTxt.text;
    placelist.type = self.type;
    [self.navigationController pushViewController:placelist animated:YES];
    [placelist release]; 
}

However this creates a new table in the navigation controller and leaves a back button to the filter eg. Home -> Placelist->Filter->PlaceList->Filter its a never ending loop when all I want is Home -> Placelist -> Filter but data can be pushed backwards. Thanks.

Bradley
  • 617
  • 2
  • 11
  • 26

3 Answers3

3

Instead of pushing view controller, you need to go for pop option, once you do the pop, viewWillAppear of PlaceList will be called, s you are using tableview, you can fetch and reload data there. There is no point in pushing again and again without popping.

rishi
  • 11,779
  • 4
  • 40
  • 59
1

You need to POP your view but i assume you want to get filtered value into first view, so you have options like

KVO

Delegates

I Strongly suggest using delegates, if you need a starting point, look at this url dismissModalViewController AND pass data back

Community
  • 1
  • 1
cnu
  • 815
  • 10
  • 22
0

After Home -> Placelist->Filter , in Filter instead of pushing view just use following

    [self.navigationController popViewControllerAnimated:YES];

This will remove Filter view from stack and your Placelist will be visible.....

Minakshi
  • 1,437
  • 1
  • 11
  • 19