Welcome, Guest
Username Password: Remember me

How to change font size for add/detail views?
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: How to change font size for add/detail views?

How to change font size for add/detail views? 1 year, 3 months ago #1

I have a simple table model derived as follows:

// Get managedObjectContext from application delegate
NSManagedObjectContext *managedObjectContext = [(LeadershipAppDelegate *)[UIApplication sharedApplication].delegate managedObjectContext];

// Create a class definition for TeamEntity
SCClassDefinition *teamDef =
[SCClassDefinition definitionWithEntityName:@"TeamEntity" withManagedObjectContext:managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"teamName", @"teamDescription", nil]];

SCPropertyDefinition *namePropertyDef = [teamDef propertyDefinitionWithName:@"teamName"];
namePropertyDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"enter team name"];
namePropertyDef.type = SCPropertyTypeTextField;
namePropertyDef.title = @"Team Name";
namePropertyDef.required = TRUE;

SCPropertyDefinition *descriptionPropertyDef = [teamDef propertyDefinitionWithName:@"teamDescription"];
descriptionPropertyDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"enter team description"];
descriptionPropertyDef.type = SCPropertyTypeTextField;
descriptionPropertyDef.title = @"Team Description";
descriptionPropertyDef.required = FALSE;

// Instantiate the tabel model
teamTableModel = [SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];

// Create and add the objects section
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
withEntityClassDefinition:teamDef];

objectsSection.addButtonItem = self.navigationItem.rightBarButtonItem;
[teamTableModel addSection:objectsSection];

I would like to have smaller font for detail/add view cell labels. Here is how I did it, but I am asking is there a better way of doing this? For example not to go through all the cells one by one, but to set the font size once for all cells.

- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillAppearForSectionAtIndex:(NSUInteger)index withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
SCObjectSection *objectSection = (SCObjectSection *)[detailTableViewModel sectionAtIndex:index];

SCTableViewCell * nameCell = [objectSection cellForPropertyName:@"teamName"];
nameCell.textLabel.font = [UIFont boldSystemFontOfSize:13];
}

I am sorry if this question was covered somewhere else in the forum. Thanks.
Last Edit: 1 year, 3 months ago by goran@dvscorp.com.

Re: How to change font size for add/detail views? 1 year, 3 months ago #2

Hi Goran,

I apologize for the delayed response as I was in the midst of the crisis in Egypt.

Your solution is perfect
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: How to change font size for add/detail views? 1 year, 3 months ago #3

Thanks Tarek.

However there is a problem. Add views are fine and font is rendered as specified. However, the detailed view (when you select a cell and get a detailed view) still uses bigger font. I expected that the code below will change font size when adding and when editing but it does not. Any idea how to fix this?

Of course with STV 2.0 I can IB to define views and cells but is there any solution for the problem I described. Thanks.
  • goran
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0

Re: How to change font size for add/detail views? 1 year, 3 months ago #4

Hi again Goran,

For detail views, you'll also need to implement the detailViewWillAppearForRowAtIndexPath method. Please tell me if you need any more help.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: How to change font size for add/detail views? 1 year ago #5

I've tried the below code to change the detail view font. It sets only first row of each sections.The second row of each section is normal font. Any thing missing? Also,How do I change font for the property values?

- (void)tableViewModel:(SCTableViewModel *) tableViewModel
detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath
withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
UITableView *detailTableView = detailTableViewModel.modeledTableView;
detailTableView.opaque = YES;
detailTableView.editing = FALSE;

//UIImage *image =[UIImage imageNamed:kBackgroundColor];
//UIImageView *imageView = [UIImageView alloc] initWithImage:image];
//detailTableView.backgroundView = imageView;
detailTableView.backgroundColor = backGrndColor;
detailTableView.separatorStyle=4;
detailTableViewModel.delegate = self;

SCObjectSection *objectSection = (SCObjectSection *)[detailTableViewModel sectionAtIndex:indexPath.row];
SCTableViewCell * nameCell = [objectSection cellForPropertyName:@"name"];
SCTableViewCell * phoneCell = [objectSection cellForPropertyName:@"phone"];
SCTableViewCell * descriptionCell = [objectSection cellForPropertyName:@"email"];
SCTableViewCell * contactsCell = [objectSection cellForPropertyName:@"title"];
SCTableViewCell * dateTimeCell = [objectSection cellForPropertyName:@"address"];
SCTableViewCell * roleCell = [objectSection cellForPropertyName:@"role"];

nameCell.textLabel.font = kDetailViewTextLableFont;
phoneCell.textLabel.font = kDetailViewTextLableFont;
descriptionCell.textLabel.font = kDetailViewTextLableFont;
contactsCell.textLabel.font = kDetailViewTextLableFont;
dateTimeCell.textLabel.font = kDetailViewTextLableFont;
roleCell.textLabel.font = kDetailViewTextLableFont;
}
  • rajdn
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Karma: 0

Re: How to change font size for add/detail views? 1 year ago #6

Hi Raj,

Your code looks fine. Are you sure that the variables (e.g. nameCell) actually contain a value at runtime?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.98 seconds