Search code examples
xcodeuitableviewios6uistoryboardback

Xcode iOS 6 - UITableView Null on Navigating Back using Storyboard


In my iOS app I am using a UITableView which is populated correctly on launch and I navigate to a subview using:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"showSubView" sender:self];
}

When the subview loads I can access the UITableView but when I navigate back using the back button on the navigation bar I want to update the table before it becomes visible to the user. I am trying to update the table in viewWillDisappear but myTableView is NULL for some reason:

- (void)viewWillDisappear:(BOOL)animated
{
[_myTableView reloadData];
}

I have declared myTableView in the header file:

@property (weak, nonatomic) IBOutlet UITableView *myTableView;

Everything is referenced correctly and all View Controllers have the same class "ViewController" so I can't understand why this isn't working! Any ideas? Thanks!


Solution

  • You should be using viewWillAppear instead of viewWillDisapear. viewDidDisappear won't be called until after the view is no longer visible.