Hi Troy,
Thanks a lot for all the complements
You can do what you're asking for through STV's SCTableViewModelDelegate methods (please make sure you conform to the SCTableViewModelDelegate protocol in your view controller's header file). First, you need to implement the willConfigureCell method:
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
willConfigureCell:(SCTableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Make sure the current section is an SCArrayOfObjectsSection before
// modifying the cell's accessory type
SCTableViewSection *section = [tableViewModel sectionAtIndex:indexPath.section];
if([section isKindOfClass:[SCArrayOfObjectsSection class]])
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
This will actually modify the cells in the main model only, and not the rest of the detail models' cells. This is because only the main model has its "delegate" property set automatically to your view controller. To have the "willConfigureCell" method get called for the rest of the detail models, you'll have to set their delegates using the following methods:
// Method is called when a detail model is created for a new item
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailModelCreatedForSectionAtIndex:(NSUInteger)index
detailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
detailTableViewModel.delegate = self;
}
// Method is called when a detail model is created for an existing item
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailModelCreatedForRowAtIndexPath:(NSIndexPath *)indexPath
detailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
detailTableViewModel.delegate = self;
}
With STV 2.0 final release (due before the end of this week), STV would automatically use the disclosure button to display the cell's detail view and you would be done here. Since you don't have the final release yet, you should manually tell STV to do that:
// Tell STV what to do when the disclosure button is tapped
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
SCTableViewSection *section = [tableViewModel sectionAtIndex:indexPath.section];
// check if the section in an SCArrayOfObjectsSection
if([section isKindOfClass:[SCArrayOfObjectsSection class]])
{
SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)section;
// Tell the section to dispatch the same event as if the cell itself was selected
[objectsSection dispatchSelectRowAtIndexPathEvent:indexPath];
}
}
Hope this helps!