Welcome, Guest
Username Password: Remember me

Add customization on the low level of STV
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Add customization on the low level of STV

Add customization on the low level of STV 1 year, 3 months ago #1

Here is what I'm trying to achieve. I have First level of navigation with UITableViewController class that contains SCTableModel. One of the cell here is actually list of objects so I'm using SCArrayOfObjectsCell and pass class definition for my class.

When user selects this cell application goes to the second level (auto-generated at this point) with list of my objects. This list has built-it ability to edit/create/rearrange objects which is great.

When user select individual object there application goes to the third level of STV (again auto-generated based on class definition).

I faced a problem that I have very little control over that third level of STV. Delegate that I passed to first level table model is not being called and I can't do things that I want to do. For example
- I would like to have ability when user editing my object to show/hide certain cells based on values in other cells
- I also wanted to be able to specify Grouped style of STV for selection cells

Is it possible using class definition approach or I need to do something else?
  • sha
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0

Re: Add customization on the low level of STV 1 year, 3 months ago #2

Hi Vladimir,

STV allows you to fully customize all automatically generated detail views, no matter how deep their level is. For your delegate methods to get called for detail views, you should set their "delegate" property to your view controller in the detailViewWillAppearForRowAtIndexPath method. Starting STV 2.0 (final version not released yet), you should use the detailModelCreatedForRowAtIndexPath to do that instead. Here is a code sample:

 
// ******* PRE-STV2.0 ********
 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath
withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
detailTableViewModel.delegate = self;
 
// Set the tag property of the detail model to correspond to its level in the hierarchy
detailTableViewModel.tag = tableViewModel.tag + 1;
}
 
 
 
// ******* STV2.0 AND LATER ********
 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailModelCreatedForRowAtIndexPath:(NSIndexPath *)indexPath
detailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
detailTableViewModel.delegate = self;
 
// Set the tag property of the detail model to correspond to its level in the hierarchy
detailTableViewModel.tag = tableViewModel.tag + 1;
}
 


Now all you need to do in the rest of the delegate methods is to identify the detail model's level using its tag, then do whatever action that's appropriate for that model. For example:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
willDisplayCell:(SCTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
switch(tableViewModel.tag)
{
case 0: // Main model
// do main level customizations here
break;
 
case 1: // Level 1 detail model
// do level 1 customizations here
break;
 
case 2: // Level 2 detail model
// do level 2 customizations here
break;
}
}
 


Hope this helps!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
Last Edit: 1 year, 3 months ago by tarekskr.

Re: Add customization on the low level of STV 1 year, 3 months ago #3

Thank you Tarek for your response. So, basically, the key is to catch delegate when we're going deeper and set model delegate to ourself. Looks like your solution almost works

For some reason detailViewWillAppearForRowAtIndexPath is not called for SCArrayOfObjectsCell cell when we're going from cell to list of objects. But... I found that you can instead (well, not instead but along with mentioned delegate) use detailViewWillAppearForCell delegate of SCTableViewCellDelegate protocol. Using these two I think you will catch everything that is needed.

May be it's a bug in pre-2 version?

Another question about customization of low level views: is it possible to break down automatically generated detail view for SCObjectCell into several sections of properties?
  • sha
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0

Re: Add customization on the low level of STV 1 year, 2 months ago #4

Hi Vladimir,

I am not able to replicate detailViewWillAppearForCell not being called for SCArrayOfObjectsCell. Are you able to post your code (or preferably send me your project to our support email)? Thanks!


is it possible to break down automatically generated detail view for SCObjectCell into several sections of properties?


Please check out the following post: www.sensiblecocoa.com/forum/general-disc...table-view.html#1783
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
Last Edit: 1 year, 2 months ago by tarekskr.
  • Page:
  • 1
Time to create page: 0.93 seconds