Reputation: 798
I will directly start from an ex: I have two classes A and B, both are derived from UITableViewController.
I have also added them into navigation controller so there is navigation going on from A to B. These both classes use database for showing data into the table. Now in B View I delete a row from the DB and A view displays the row count of that DB table. Now what I am doing is on the BACK button of the navigation I want to I am calling this method TRY 1:
//in class B
-(IBAction)backBtnPressed
{
[ObjA.tbleView reloadData];
[self.navigationController popViewControllerAnitmated:YES];
}
on its action. The problem is this method does not reload the data of View A. i.e., it doesn't call the tbleView's delegate methods like cellForIndexPath...etc. Then I thought that may the reloadData shud be called from the same class so did this TRY 2:
//in class B
-(IBAction)backBtnPressed
{
[ObjA.tbleView myReloadData];
[self.navigationController popViewControllerAnitmated:YES];
}
//Class A
-(void)myReloadData
{
[self.tbleView reloadData];
}
It comes into this method but still doesn't call the tableView delegate methods. Please let me know why I am not able to do this silly thing :(. Regards.. Amit
Upvotes: 1
Views: 770
Reputation: 5069
You're close, put this in class A:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
Upvotes: 0
Reputation: 4642
Have you connected the UITableView
's delegate
and dataSource
outlets correctly (either in your nib or using code, depending on how you create the table)?
Upvotes: 1