change color of UITableViewCell after reenabled userinteraction
Asked Answered
S

1

0

in my app, i've some menupoints, that are disabled for userinteraction.

   cell.userInteractionEnabled = FALSE;

after the login, i want to reenable some of these cells.

this snippet is working half the way:

   NSIndexPath *editUsersPath = [NSIndexPath indexPathForRow:0 inSection:1];
        [self.tableView cellForRowAtIndexPath:importPath].userInteractionEnabled = YES;
        [self.tableView cellForRowAtIndexPath:importPath].accessoryType =         UITableViewCellAccessoryDisclosureIndicator;
        [self.tableView cellForRowAtIndexPath:importPath].textLabel.textColor = [UIColor blackColor];

but the last line of code is not working - the text is gray as before.

Silviasilviculture answered 1/11, 2011 at 14:28 Comment(0)
Q
0

Are you doing any cell redrawing after the changes? Perhaps you can try calling setNeedsLayout to redraw the cell.

Quirt answered 1/11, 2011 at 14:39 Comment(8)
i tried it - but there are no changes for the textcolor. by the way: i can change the backgroundcolor...Silviasilviculture
After setting userInteractionEnabled, is userInteractionEnabled actually YES? Throw an NSLog after that line before and after and see if the value updates correctly.Quirt
I also see another post about a similar issue you might want to check out. #7793991Quirt
yes - it's userenabled. i tried with a NSLog - and it's also touchable. i moved the "userInteractionEnabled = TRUE" at the end, after changing the textcolor. but it doesn't change anything.. [self.tableView cellForRowAtIndexPath:editUsersPath].accessoryType = UITableViewCellAccessoryDisclosureIndicator; [[self.tableView cellForRowAtIndexPath:editUsersPath].textLabel setTextColor:[UIColor blackColor]]; [self.tableView cellForRowAtIndexPath:editUsersPath].userInteractionEnabled = YES; [[self.tableView cellForRowAtIndexPath:editUsersPath] setNeedsDisplay];Silviasilviculture
After reading that other post more closely it looks like he's doing the opposite of what you want to do. Where are you calling all this code? Seems like the place to do this would be in willDisplayCell where you can check for a flag for loggedIn to toggle cell usability there.Quirt
after the login, i'm calling the method "UserLoggendIn". i'm wondering, because i can change everything at the label.. backgroundcolor, the text, accessoryType, ... the only thing i can't change is the textcolor..Silviasilviculture
I noticed today while I was playing around with tableviews that if you do something like [cell setUserInteractionEnabled:NO] and do [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator] the cell interaction will be disabled but the text will be black. Doing [cell setAccessoryType:UITableViewCellAccessoryNone] in the same conditional as [cell setUserInteractionEnabled:NO] actually set the cell text color to grey as it should be. I wonder if something similar is happening to you.Quirt
no - that's not the same with me.. i thinks it's a bug - now i'm changing the datasource of the table and reload it after setting the userrights.think this looks just nicer..Silviasilviculture

© 2022 - 2024 — McMap. All rights reserved.