Welcome, Guest
Username Password: Remember me

Grouping cells in detailView into sections
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Grouping cells in detailView into sections

Grouping cells in detailView into sections 1 year, 6 months ago #1

How would I go about breaking up the detailTableView cells generated from a SCObjectSection cell tap into sections? I know how to customize the cells in a detailView just trying to figure out how to group some of those cells into sections perhaps even using ClassDefs.

Thanks!
  • kes815
  • OFFLINE
  • Junior Boarder
  • Posts: 32
  • Karma: 0

Re: Grouping cells in detailView into sections 1 year, 6 months ago #2

Hi Karl,

Let's say that you need to distribute the cells automatically generated by STV into two sections, A and B, instead of just being in only one section. Here is a quick idea that you can implement in tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel:

a. Create sections A & B as normal SCTableViewSection instances, and add them to the detailTableViewModel.

 
SCObjectSection *sectionA = [SCObjectSection sectionWithHeaderTitle:@"Section A"];
[detailTableViewModel addSection:sectionA];
SCObjectSection *sectionB = [SCObjectSection sectionWithHeaderTitle:@"Section B"];
[detailTableViewModel addSection:sectionB];
 


b. Add the relevant cells from the original detail section into these two sections. For example:

 
[sectionA addCell:[[detailTableViewModel sectionAtIndex:0] cellAtIndex:1]];
 


c. Remove the original section:

 
[detailTableViewModel removeSectionAtIndex:0];
 


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

Re: Grouping cells in detailView into sections 1 year, 6 months ago #3

Works beautifully! Only hitch I see now is the cancel button doesn't appear to rollback changes. It does work when I use the original section. Ideas on what I might be doing wrong?
  • kes815
  • OFFLINE
  • Junior Boarder
  • Posts: 32
  • Karma: 0

Re: Grouping cells in detailView into sections 1 year, 6 months ago #4

You'll have to set your new sections' commitCellChangesLive property to FALSE.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Grouping cells in detailView into sections 1 year, 6 months ago #5

Where would be the appropriate place to call commitCellChanges for each section I set commitCellChangesLive = FALSE? The changes in the detailView are not being applied to the bound object so suspecting this is what I need to do just can't figure out where to do it.
  • kes815
  • OFFLINE
  • Junior Boarder
  • Posts: 32
  • Karma: 0

Re: Grouping cells in detailView into sections 1 year, 6 months ago #6

Hi Karl,

Sorry if I wasn't clear about this. You should do it in the same function call:

 
sectionA.commitCellChangesLive = FALSE;
sectionB.commitCellChangesLive = FALSE;
 
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 0.92 seconds