Eric Brotto Eric Brotto - 1 year ago 80
Objective-C Question

UITableView delegate not called when UIViewController is popped

I have a view controller that contains a UITableView. When the view controller gets pushed onto the stack, the table view delegate methods get called and it populates the table.

Then I push another view controller onto the one that contains the table view. What I would like to make happen is that - when the second view controller gets popped and I return to the previous view controller, those uitableview delegate methods get called again (so as to repopulate the table).

In other words, how do you repopulate a uitableview when popping to a view controller.


Answer Source

In viewDidLoad or viewDidUnload, viewWillAppear, viewWillDisappear (whichever of these is right for your situation) you can put [myTable reloadData];:

// If you can include some code it would help as I am a bit uncertain
// about exactly what you are trying to do from the question but
// you should use whichever of these is correct for project:

- (void)viewDidLoad {
    [super viewDidLoad];
    [myTable reloadData];

- (void)viewDidUnload {
    [myTable reloadData];

- (void)viewWillAppear {
    [super viewWillAppear];
    [myTable reloadData];

- (void)viewWillDisappear {
    [super viewWillDisappear];
    [myTable reloadData];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download