Is anyone else experiencing this problem where if you programmatically set the selected state of a UITableViewCell to YES, it colors the text label black?
[cell setSelected:YES]
I can't seem to figure this out. I would expect it to highlight the cell blue. Manually selecting the cell works as it colors the cell blue while the text is displayed in white.
Any help is appreciated. Thanks in advance!
I was having the same problem and fixed it by moving the cell.selected = YES into tableView:willDisplayCell:forRowAtIndexPath instead.
I think it might be related to the note at the bottom of the UITableViewCell docs about changes to background color requiring use of tableView:willDisplayCell:forRowAtIndexPath (presumably selected sets the background color).
Related
When I select a cell using the cell selection button , the design of the cell changes.
There is a blue line in the bottom (may be due to selection highlighting)
and the round corner changes to light blue.
Please suggest ways to solve this issue. I don't want these two effects.
Try something like this:
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
I am having issues setting the cell background colour on a grouped table cell when in edit mode. It seems to get the checkmark to appear a selection style has to be set and the only options are UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleGray.
What I am after is the for the checkmark just to be selected and the cell remain white when it is checked.
You would have thought UITableViewCellSelectionStyleNone would have this behaviour but this stops the checkmark for showing.
I have tried to use setSelectedBackgroundView. This would work if the cell style was not grouped but as it is the round corners do not get drawn.
The properties for the cell above are
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.backgroundView = [self tableViewCellRowBackground];
Where tableViewCellRowBackground is a UIView with orange background.
The editMode is the built in iOS table edit mode with the following properties set on the table
self.tblFiles.allowsSelectionDuringEditing=YES;
self.tblFiles.allowsMultipleSelectionDuringEditing = YES;
Any ideas?
cell.backgroundView = [self tableViewCellRowBackground];
This method is setting an image for your selected cell.You should check out this one to make the selection Style image nil.
In the end I had to create my own custom cells by overriding the drawrect method.
I made a custom cell for a UITableView (subclassing UITableViewCel, e..., and with a xib). In IB, i set the background color of the myUITableViewCell to a light grey. Simulated into IB (with a run), the cell looks great (a full grey even under the disclosure button). But when I run the application, the cell keeps showing a white background. Do you know why this happens ?
May I have to do this programmaticaly to make it work ?
Do you init the cell with initWithNibName:#"YOURXIBFILE" ...?
Did you overwrite the drawRect Method?
yea, there is some problems to create custem cell with IB.
try write it in code, you can see a tutorial how to do this:
http://blog.webscale.co.in/?p=284
I found a great help at : Setting background color of a table view cell on iPhone
In fact it seems that this behaviour needs coding... a very few lines, as the color set in IB is cleared at draw time. So the background color have to be set in the "willDisplayCell" tableview delegate method.
HI,
I am using a UITableView to display listings. I have customized it and have added 4 UILabels in the cell, but when the row is selected then the row selection color (customized to green) and Label text color (also a green) remains same. So, it becomes difficult to see the text of cell. I want to change the color of labels to white when row is selected otherwise green.
Can anyone help me out?
Thanks,
Look at the highlightedTextColor property on the labels. Set that to white and it should do what you want.
If you’re subclassing UITableViewCell, there’s always the -setSelected:animated: method to override.
My UITableViewController uses a custom UITableViewCell Subclass.
The subClass (QuoteCell - loaded from NIB) has a few UILabels and a UIImageView on it.
Works fine, however, when I tap on the cell, the cell highlights, but the UILabels on the cell don't reverse colors.
I thought this was stock behavior??
Any help appreciated, Thanks!
btw: There's nothing in the didSelectRowAtIndexPath method yet.
I found the answer, after reading comments from Jasarien and Prakash.
Apparently, in IB, you manually have to select a highlight color to see the behavior.
By default, UILabel color is Black and the highlight color apparently is also Black, which is strange because it has that half black, half white diagonal. I would think the behavior would be different.
Anyway, I changed the color to solid white and got the highlighted behavior I was expecting.
I wonder why you need to show the row selection?
You could do this
cell.selectionStyle = UITableViewCellSelectionStyleNone;
and handle your row selection logic as-is..
You have to write the code to swap the text colour of the label yourself.
The best place for that would probably be in -setHighlighted:animated: