Welcome, Guest
Username Password: Remember me

Reload DetailTableViewModel's cell accessories
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Reload DetailTableViewModel's cell accessories

Reload DetailTableViewModel's cell accessories 1 year, 7 months ago #1

Hi,

I have a UITableViewController on which I'm pushing various STV DetailTableViewModels. This subclass is the only class I have to render three or four DetailTableViewModels. That works great.

Now I need to reload the data (especially the accessoryView) of cells which sit in one of these DetailTableViewModel.
[self.tableView reloadData] doesn't help, because it seems that this only affects the cells from the root table view (self.tableView in a UITableViewController subclass), and not the DetailTableViewModels.

So, how do I reload these DetailTableViewModels?

Thanks,
Patrick
  • Patrick
  • OFFLINE
  • Senior Boarder
  • Posts: 49
  • Karma: 3

Re: Reload DetailTableViewModel's cell accessories 1 year, 7 months ago #2

Hi Patrick,

If I understand you correctly here, all you need to do is call [myDetailTableViewModel.modeledTableView reloadData] . Please tell me if I am missing something here.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Reload DetailTableViewModel's cell accessories 1 year, 7 months ago #3

Hi Tarek,

I forgot to mention that I need to call that method in an method which is being called when the user switches the active tabBarItem (it's UITabBarControllDelegate's )tabBarController: didSelectViewController: method).

In this method I have no information about the current detailTableViewModel. How do I get the detailTableViewModel, which is currently being showed? As I mentioned, I have multiple detailTableViewModels.
  • Patrick
  • OFFLINE
  • Senior Boarder
  • Posts: 49
  • Karma: 3

Re: Reload DetailTableViewModel's cell accessories 1 year, 7 months ago #4

Hi again Patrick,

I am sure there are many ways to do this, but here is what first comes to my mind:

1- Create a class called MyViewController which subclasses UITableViewController, then create an SCTableViewModel retain property called tableModel for example.

2- Have MyViewController as a superclass for all your view controllers and delete any tableModel member variables you already have (they will get that from their superclass).

3-
 
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController
{
[((MyViewController *)viewController).tableModel.modeledTableView reloadData];
}
 



Hope this helps.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Reload DetailTableViewModel's cell accessories 1 year, 7 months ago #5

Thanks, Tarek.

This works fine, even though I had to adjust the delegate method's code, because my UITabBarController is holding UINavigationControllers and not UIViewControllers. (Of course you couldn't know that. )

- (void)tabBarController:(UITabBarController *)tabBarController 
didSelectViewController:(UIViewController *)viewController {
 
if ([viewController isKindOfClass:[UINavigationController class]]) {
 
UINavigationController *tempNavController = (UINavigationController *)viewController;
SCTableViewController *tempTableViewController = (SCTableViewController *)tempNavController.topViewController;
 
if ([tempTableViewController isKindOfClass:[SCTableViewController class]]) {
[tempTableViewController.tableViewModel.modeledTableView reloadData];
}
 
}
}
  • Patrick
  • OFFLINE
  • Senior Boarder
  • Posts: 49
  • Karma: 3
Last Edit: 1 year, 7 months ago by Patrick.
  • Page:
  • 1
Time to create page: 0.94 seconds