Question

I have a UIViewController with a container view which holds a UITableView.

Within the UITableView I have a NSFetchController with NSPredicate that uses variables from the intial UIViewcontroller (I hope your still with me). For one instance that the user changes the container view does not update.

How can I force a reload/update on the container view when this occurs? I looked around but did not see much on this topic.

To be specific I have a UIDatePicker that changes the date on a button. It is this that needs to be updated.

enter image description here

Was it helpful?

Solution

From the initial UIView controller, you can get a reference to the table view controller with self.childViewControllers[0]. So, you need to do it like this:

UITableViewController *tbc = (UITableViewController *)self.childViewControllers[0];
[tbc.tableView reloadData];

OTHER TIPS

You wrote that you have UIViewController there and not UITableViewController - if you have UIViewController you have to have a property there. I assume that here everything is ok.. But check.

What I am doing while working with containers views is adding element by:

_someVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SomeVC"];
[self addChildViewController:_someVC];
_someVC.view.frame = _containerView.bounds;
[_containerView addSubview:_someVC.view];
[_someVC didMoveToParentViewController:self];

And not with IB. Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top