Welcome, Guest
Username Password: Remember me

White block for textLabel
(1 viewing) (1) Guest

TOPIC: White block for textLabel

White block for textLabel 1 year, 8 months ago #1

Hi!

I'm trying to customize the look of a specific row (color, etc) but i'm getting "white rectangle" doing so. Is a matter of the order of my coloring and clearing?

 
- (void)tableViewModel:(SCTableViewModel *) tableViewModel willDisplayCell:(SCTableViewCell *) cell forRowAtIndexPath:(NSIndexPath *) indexPath
{
 
if([cell isKindOfClass:[SCControlCell class]])
{
[(SCControlCell *)cell control].backgroundColor = [UIColor clearColor];
}
 
cell.textLabel.backgroundColor = [UIColor clearColor];
 
// Set up the cell...
NSUInteger row = [indexPath row];
 
if( row == 0 )
{
cell.backgroundColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor whiteColor];
}
else
{
cell.backgroundColor = [UIColor whiteColor];
cell.textLabel.textColor = [UIColor blackColor];
}
}
 


Thanks!
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 149
  • Karma: 8

Re: White block for textLabel 1 year, 8 months ago #2

Hi codebonbon,

Your code is working perfectly for me. What are the cell types that are giving you this problem?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: White block for textLabel 1 year, 8 months ago #3

Hi again!

The cell that i use are core data bound. Here's a sample of my viewDidLoad

 
- (void)viewDidLoad {
[super viewDidLoad];
 
// Set up the edit and add buttons.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
 
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
 
// Creation de nouvelles instances des entites
AppDelegate_Shared *appDelegate = [[UIApplication sharedApplication] delegate];
self.managedObjectContext = [appDelegate managedObjectContext];
 
 
// Create a class definition for AdresseEntity
SCClassDefinition *adresseDef =
[SCClassDefinition definitionWithEntityName:@"Adresse"
withManagedObjectContext:self.managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"rue", @"ville", @"province",@"pays",@"codePostal", nil]];
 
 
// Create a class definition for ProprieteEntity
SCClassDefinition *proprieteDef =
[SCClassDefinition definitionWithEntityName:@"Propriete"
withManagedObjectContext:self.managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"adresse", nil]];
 
proprieteDef.titlePropertyName = @"adresse.rue";
 
 
SCPropertyDefinition *adressePropertyDef = [proprieteDef propertyDefinitionWithName:@"adresse"];
adressePropertyDef.attributes = [SCObjectAttributes attributesWithObjectClassDefinition:adresseDef];
 
// Instantiate the tabel model
tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
 
// Create and add the objects section
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
withEntityClassDefinition:proprieteDef];
 
objectsSection.addButtonItem = self.navigationItem.rightBarButtonItem;
[tableModel addSection:objectsSection];
}
 


Thanks!
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 149
  • Karma: 8

Re: White block for textLabel 1 year, 8 months ago #4

Sorry to bug you again, but would you please post a screen shot, as I am still unable to replicate your problem. Thanks.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: White block for textLabel 1 year, 8 months ago #5

Here you go!

Here are the step i do to get this behaviour in the simulator. I add an item with the '+' button. Fill in some detail. Save the item and go back. Then i select the same item again but this time i don't change anything in the detail view. Then go back to this screen shot.

Thanks!

Screenshot_1.png
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 149
  • Karma: 8

Re: White block for textLabel 1 year, 8 months ago #6

Hi again Harold:

I'll send you now a new RC version of Sensible TableView that handles all the background color issues for you automatically. You new code should look like this:

 
- (void)tableViewModel:(SCTableViewModel *) tableViewModel willDisplayCell:(SCTableViewCell *) cell forRowAtIndexPath:(NSIndexPath *) indexPath
{
// Set up the cell...
NSUInteger row = [indexPath row];
 
if( row == 0 )
{
cell.backgroundColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor whiteColor];
}
else
{
cell.backgroundColor = [UIColor whiteColor];
cell.textLabel.textColor = [UIColor blackColor];
}
}
 


Please tell me if the new version works well for you
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
Time to create page: 1.11 seconds