Reputation: 617
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.
Upvotes: 0
Views: 340
Reputation: 815
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
Upvotes: 1
Reputation: 1433
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.....
Upvotes: 0
Reputation: 11839
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.
Upvotes: 3