Welcome, Guest
Username Password: Remember me

Noob question1 - How do I split up a grouped table view?
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Noob question1 - How do I split up a grouped table view?

Noob question1 - How do I split up a grouped table view? 1 year, 4 months ago #1

Where and how do I split a grouped table view into (2) sections.

Thanks

David
Last Edit: 1 year, 4 months ago by daviddelmonte. Reason: Better title

Re: Noob question1 - How do I split up a grouped table view? 1 year, 4 months ago #2

Hi David,

Are you adding the cells yourself, or are they being automatically generated via a class definition? It would be helpful if you can post some code.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Noob question1 - How do I split up a grouped table view? 1 year, 4 months ago #3

The cells are auto generated.... I think here:



 
 
- (void)viewDidLoad {
[super viewDidLoad];
// NSLog(@"%s", __FUNCTION__);
// Set up the edit and add buttons.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
 
 
// Create PresentEntity class def
SCClassDefinition *presentDef = [SCClassDefinition definitionWithEntityName:@"PresentEntity" withManagedObjectContext:self.managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"firstSingle", @"secondSingle", @"thirdSingle", @"firstPlural", @"secondPlural", @"thirdPlural", nil]];
 
 
 
 
 
SCClassDefinition *verbDef = [SCClassDefinition definitionWithEntityName:@"VerbEntity" withManagedObjectContext:self.managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"name", @"translation", @"present", @"simplePast", @"simpleFuture", @"contPast", @"contFuture", nil]];
 
[verbDef propertyDefinitionWithName:@"name"];
[verbDef propertyDefinitionWithName:@"present"].attributes = [SCObjectAttributes attributesWithObjectClassDefinition:presentDef];
[verbDef propertyDefinitionWithName:@"simplePast"].attributes = [SCObjectAttributes attributesWithObjectClassDefinition:sPastDef];
[verbDef propertyDefinitionWithName:@"simpleFuture"].attributes = [SCObjectAttributes attributesWithObjectClassDefinition:sFutureDef];
 
SCPropertyDefinition *namePropertyDef = [verbDef propertyDefinitionWithName:@" "];
namePropertyDef.title = @" ";
 
 
 
// Instantiate the table model
 
tableModel = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView withViewController:self
withEntityClassDefinition:verbDef];
 
 
 
 
@end
 
 

Re: Noob question1 - How do I split up a grouped table view? 1 year, 4 months ago #4

Hi David,

Thanks for the code. You'll need to create a new section when the detail view is about to appear, and move the name cell to that section. Here is a code sample illustrating this:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailViewWillAppearForSectionAtIndex:(NSUInteger)index
withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
SCTableViewSection *verbSection = [detailTableViewModel sectionAtIndex:0];
SCTableViewCell *nameCell = [verbSection cellAtIndex:0];
 
// Create new section
SCObjectSection *newSection = [SCObjectSection section];
newSection.commitCellChangesLive = FALSE; // allow user to cancel changes by tapping Cancel
[newSection addCell:nameCell];
[detailTableViewModel insertSection:newSection atIndex:0];
 
// Remove the nameCell from the original section
[verbSection removeCellAtIndex:0];
}
 


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

Re: Noob question1 - How do I split up a grouped table view? 1 year, 4 months ago #5

Amendment: Please note that the above code will modify the detail view for newly created items only. To modify the detail view of items being edited, you'll also have to implement the tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel: method (with the same code above).
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Noob question1 - How do I split up a grouped table view? 1 year, 2 months ago #6

Tarek, I'm not sure how to implement these (two?) methods.

Do I need both?

How are they called? From where?

Where do I define the split between sections?

Right now, I do not have a detailview called..

Thanks as always for the help..

David
  • Page:
  • 1
  • 2
Time to create page: 2.02 seconds