Reputation: 4973
I need to tell a uitableview to reloadData when something happens on another view (or at least that is what I think I need to do) how do I do it??
the uitableview is just an IBOutlet of a uitableviewcontroller object.
more details: So i have an array of data as kind of a database and a user creates objects to populate the database on view 1 of a tabBar app. view 2 is basically is a view that displays all the objects in the the same "database" array. the array is kept in the app delegate.
The app will show updates on a relaunch in the table view but not on a switch from view 1 to view 2, say after a user creates an object instance in view 1.
EVEN more details!!!
I just noticed that the first time through if you enter in data on view 1 and then go to view 2 the data new data you just added is there but if you go to view 2 before entering any data and then go back to view 1 the UItaableview in view 2 will not update until you relaunch.
Thanks
Nick
Upvotes: 0
Views: 72
Reputation: 2006
If the controller in tab 2 is a UIViewController with a UITableView property set as an IBOutlet, do the following:
- (void)viewWillAppear:(BOOL)animated
{
[self.tableView reloadData];
}
If your view controllers are UITableViewControllers, then they already have tableView properties and perform the above behavior on their own. If you are creating your own tableView property on UITableViewControllers, then you are overriding behavior that is already there and probably breaking functionality.
Upvotes: 1
Reputation: 523214
If you have the UITableViewController object, just call
[theTableViewController.tableView reloadData];
Upvotes: 0