Welcome, Guest
Username Password: Remember me

Change cell type using SCArrayOfObjectsSection
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Change cell type using SCArrayOfObjectsSection

Change cell type using SCArrayOfObjectsSection 1 year, 7 months ago #1

I have a Twitter feed parser that give me a NSMutableArray of NSMutableDictionaries that hold the data.

This is how I am initializing STV:

_tableViewModel = [SCTableViewModel alloc] initWithTableView:_tableView withViewController:self];


After my parser calls my delegate method letting it know that it has finished downloading the feed, I do this:

 
 
- (void)receivedItems:(NSMutableArray *)theItems
{
_items = theItems;
 
SCDictionaryDefinition *twitterDef = [SCDictionaryDefinition definitionWithDictionaryKeyNames:[NSArray arrayWithObjects:@"title", nil]];
twitterDef.titlePropertyName = @"title";
 
SCArrayOfObjectsSection *section = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withItems:_items withClassDefinition:twitterDef];
 
[_tableViewModel addSection:section];
 
section.allowEditDetailView = NO;
 
[_tableView reloadData];
 
[_activityIndicator stopAnimating];
}
 


This works (I only want a tableview with a row for each tweet). However, is there a way to change the cell type? It seems it is of SCTextFieldCell where I would like to be using SCTextViewCell (for the auto grow).

Thanks!
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5

Re: Change cell type using SCArrayOfObjectsSection 1 year, 7 months ago #2

Just simply change the type of "title" property definition to SCPropertyTypeTextView:

 
..
[twitterDef propertyDefinitionWithName:@"title"].type = SCPropertyTypeTextView;
..
 


Also please have a look on how we define cell types in our sample applications and our video tutorials.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Change cell type using SCArrayOfObjectsSection 1 year, 7 months ago #3

That changes the cell types of the detaiView though, correct? I was wondering about the main tableView cell types.
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5

Re: Change cell type using SCArrayOfObjectsSection 1 year, 7 months ago #4

Yes you're correct, it will change the detail view cell type. The main view cells not of type SCTextFieldCell (that's why I got confused), but rather normal SCTableViewCell(s) that decend directly from UITableViewCell. If you want to display more data in an SCTableViewCell, just increase its height and set its label's (either textLabel or detailTextLabel) lineBreakMode to UILineBreakModeWordWrap, and numberOfLines to zero. You can either set all cells to the same height, or dynamically determine the cell's height using the NSString method called sizeWithFont:constrainedToSize:lineBreakMode:.

Also, we may in the future add the option for SCTableViewCell to automatically grow to fit its labels' contents, although no one has requested this yet.

Hope this helps
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Change cell type using SCArrayOfObjectsSection 1 year, 7 months ago #5

Thanks Tarek
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5
  • Page:
  • 1
Time to create page: 0.94 seconds