IanTimmis
IanTimmis

Reputation: 815

Reload Table when View Controller has been navigated backwards to

I have a table in one view controller and a "+" button to add to the table. The "+" button brings you to the next view controller, which contains a dialog and a "Save" button to add a new item to the table. upon clicking the save button i use the function

[self.navigationController popViewControllerAnimated:YES];

to bring it back to the previous viewController with the table. The table does not repopulate by itself and until i go back one more view controller and then reopen (which re-initializes it)

So i was thinking i could use this function

[self.tableView reloadData];

to reload it upon opening the viewController when i have navigated backwards to it.

Is there a function that is called when a viewController is viewed after clicking the back button on the next viewController?

Any help is greatly appreciated!

Upvotes: 1

Views: 58

Answers (1)

CrimsonChris
CrimsonChris

Reputation: 4641

It sounds like you want viewWillAppear. UITableViewController's do some stuff already in viewWillAppear but you need to subclass in order to have it reload the table as well.

https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewController_Class/Reference/Reference.html

Upvotes: 2

Related Questions