Refresh Container View on Button Press

I have a UIViewController with a view of a container that contains a UITableView .

In a UITableView, I have an NSFetchController with an NSPredicate that uses variables from the intial UIViewController (hope you are still with me). For one instance that the user changes, the container view is not updated.

How can I force reload / refresh the container view when this happens? I looked around, but did not see much on this subject.

To be specific, I have a UIDatePicker that changes the date to a button. That is what needs to be updated.

enter image description here

+8
ios container-view
source share
2 answers

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

 UITableViewController *tbc = (UITableViewController *)self.childViewControllers[0]; [tbc.tableView reloadData]; 
+15
source share

You wrote that you have a UIViewController, not a UITableViewController - if you have a UIViewController, you should have a property. I assume that everything is fine here .. But check.

What I do when working with container views adds an element:

 _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 this helps.

0
source share

All Articles