Reputation: 1227
I have a tableivew that gets loaded from a PLIST ... works Great, I press the "+" icon at top of screen to present a detailview with text fields ... I enter data into text fields, and press a button to write data to PLIST ... PList is updated, now I use the following line to pop the view: (i am doing this is in the DetailView.m)
[self.navigationController popToRootViewControllerAnimated:YES];
I have two methods, that were recommended from what I am trying to do:
- (void) navigationController:(UINavigationController *) navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
[self.tableView reloadData];
}
-(void) navigationController:(UINavigationController *) navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
[self.tableView reloadData];
}
I am told these are the methods that will fire upon return, I have run in Debug and they don't fire upon return, am I missing something? Please help if you can, I am on a deadline and any help would be appreciated.
Upvotes: 3
Views: 1298
Reputation: 62676
I don't think you need those navigation delegate methods at all. Instead, in the view controller containing the table, reload the data on viewWillAppear.
// MyTableContainingViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
If the view controller is a subclass of UITableViewController, the reload is performed the first time the view is loaded, so my suggestion will generate an extra reloadData the first time. You can either just let that go or qualify as follows...
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (![self isBeingPresented]) {
[self.tableView reloadData];
}
}
Upvotes: 0
Reputation: 6431
It sounds like you are using the "Master-Detail" setup. If so, on the iPad the masterViewcontroller and the detailViewcontroller are not connected to the same navigation controller and so the two UINavigationControllerDelegate methods you listed will not work. If however your setup has them on the same navigationController then in the viewDidLoad method of the viewcontroller where you want to reload the table (the masterVC), you need to add
self.navigationController.delegate = self;
and then in the respective .h file you need to do something like this:
@interface MasterViewController : UIViewController<UINavigationControllerDelegate>
Upvotes: 0
Reputation: 6432
I believe the problem is that you didn't set your 'rootViewController' as the delegate of the UINavigationController
.
To do this you have to make your 'root view controller' class conform to the UINavigationControllerDelegate
protocol. Like so:
In the .h file:
@interface MyViewController : UIViewController <UINavigationControllerDelegate>
And then, in the .m file you have to implement the UINavigationControllerDelegate
methods (which you already have)
Finally, somewhere in your class (like in the viewWillLoad or viewDidLoad methods) you have to set it as the Navigation Controller delegate, like so:
self.myNavigationController.delegate = self;
I'm making several assumptions about your code. As soon as you post more I will update my answer.
Hope this helps!
Upvotes: 1