Reputation: 4929
I have a tabBar application. There are 2 UIViewControllers A and B. UIViewController B has UITableView. I call method in A UIViewController from B UIViewController: [b someMethod:someObject];
Here is code:
-(void) someMethod:someObject
{
[tableViewDataArray addObject: someObject];
[tableView reloadData];
}
But UITableView doesn't reload until I switch UIViewController to B; How to reload it without switching? If this possible
Upvotes: 1
Views: 5415
Reputation: 689
your best solution is to put a button on the toolbar for adding and refreshing and make a function called add()
and connect it to the button. and inside there you do :
-(void) add:someObject
{
[tableViewDataArray addObject: someObject];
[tableView reloadData];
}
I was having a similar issue and this actually worked, this should help : How to Reload a UITableView While I am Looking at It
Upvotes: 1
Reputation: 53551
UITabBarController
doesn't load all its tabs' views until they are actually needed, so your table view probably doesn't even exist (i.e. is nil
) before you switch to the tab that contains it.
While you could force the view controller to load its view hierarchy by accessing its view
property, I wouldn't recommend it. What's the point of reloading an invisible table view anyway?
Upvotes: 0