UA-17470720-3

Jump to content


Photo
- - - - -

Custom SCTableViewController is not used in generated detail view


  • Please log in to reply
10 replies to this topic

#1 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 11 July 2015 - 12:14 PM

I'm working with XCode 6.4 / STV 4.2.5 in 'visual' development mode and have the following issue:

  • My data model looks something like this: Site (1) -> Array (N)
  • Through a custom SCTableViewController class, I'm loading a custom cell to be within a SCArrayOfObjectsSection for both Site and Array
  • This does exactly what I expected Site (SitesTableViewController : SCTableViewController) for all scenarios
  • For Array it seems to ignore the custom class (ArraysTableViewController : SCTableViewController)when adding Arrays to an existing Site

So the above only happens if I'm adding Arrays to an existing Site. When creating Site and Arrays in one go the custom cell for Array is loaded as expected.

 

 Hope to find out what I'm doing wrong here. :-)

 

 

 

 



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 July 2015 - 12:29 PM

Hi Patrick,

 

How do you assign the custom cell to 'Array'? Let me know if the relationship between 'Site' & 'Array' is similar the relationship between 'Task' & 'TaskStep' in our sample app and I'll attach a sample with custom cells.



#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 July 2015 - 12:36 PM

I just reread your post and I think I misunderstood the problem in my first reply. Is it correct that your problem isn't custom cells related, but rather that your detail view controller is ignoring the custom class you specified in IB's Object Inspector? If it's the latter, then this should never happen in principle, and I'd like you to elaborate more on what makes you think it's ignoring the 'ArraysTableViewController' class.



#4 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 11 July 2015 - 01:06 PM

Hi Tarek,

 

Thank you for looking into this but in no hurry. :-)

 

Relations are pretty much exactly the same as Tasks and TaskStep. In both cases (SitesTableViewController ArraysTableViewController), I use the code for both Site and Array table view controllers as they are using the same SCCustomCell. It will only run this code when creating a new Site (Task in your case) and Array (TaskStep) in one go. After saving the Site (Task) and when viewing or editing, this code is called only for Site (Task). 

 

- (void)viewDidLoad {

    

    [super viewDidLoad];

    

    SCArrayOfObjectsModel *objectsModel = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView];

    

    ...

    

    self.tableViewModel = objectsModel;

    

    self.tableViewModel.sectionActions.cellForRowAtIndexPath = ^SCCustomCell*(SCArrayOfItemsSection *itemsSection, NSIndexPath *indexPath)

    {

        SCCustomCell *customCell = [SCCustomCell cellWithText:nil objectBindingsString:nil nibName:@"SiteArrayListCustomCell"];

        

        return customCell;

    };

 

}

 

 



#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 July 2015 - 01:21 PM

I am not sure why 'viewDidLoad' is not being called for your detail view controller (I can checkout your project if you wish), but there is an alternative much easier way to set your custom cell directly in IB without any code. In our TasksApp bundled sample, you would simply select the 'taskSteps' property definition and set type nib name inside the 'uiElement Nib' field in the object inspector (please see attached image).

 

Attached File  uiElementNib.png   236.81K   23 downloads

 

Hope this helps.

 

 



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 July 2015 - 01:33 PM

I think I need some coffee urgently :) My previous solution only works in STV 5.0 beta. For the latest 4.2.5 version you have, you would add the following code to MasterViewController.m:

 

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    SCDataDefinition *taskDef = [self dataDefinitionWithIBName:@"Task"];
    
    SCPropertyDefinition *taskStepPDef = [taskDef propertyDefinitionWithName:@"taskSteps"];
    taskStepPDef.cellActions.detailModelConfigured = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
    {
        detailModel.sectionActions.cellForRowAtIndexPath = ^SCCustomCell*(SCArrayOfItemsSection *itemsSection, NSIndexPath *indexPath)
        {
            SCCustomCell *customCell = [SCCustomCell cellWithText:nil objectBindingsString:nil nibName:@"MyCustomStepCell"];
            
            return customCell;
        };
    };
}


#7 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 13 July 2015 - 12:56 PM

Hi Tarek,

 

Thank you so much for clearing this up. Tried the 'uiElement nib' on 4.2.5 but couldn't get things to fly; glad to hear the 5.0 beta does the job. 

 

If there's a way I could try the beta for my app I'd love to give it a go. If there's an upgrade fee involved to pay for your coffee: yes please. :-)

 

Kind regards,

 

Patrick



#8 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 13 July 2015 - 01:08 PM

Hi Tarek,

 

Just to let you know, the solution you proposed works like a charm.  :)

 

Patrick



#9 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 13 July 2015 - 02:21 PM

Awesome! Please let me know if you still need a beta and I could wrap something up for you by tomorrow (requires Xcode 7).



#10 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 13 July 2015 - 10:56 PM

Yes please, thank you! :-) 



#11 Patrick Bovens

Patrick Bovens

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 14 posts
Reputation: 3
Good

Posted 14 July 2015 - 10:33 AM

Am all set up with the latest betas, looking forward to working with STV 5. :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users