Reputation: 729
My Tableview cells expand when tapped, to show more information in 3 UITextViews.
But the cell changes color (as i want it to), and this hides the UITextViews, but not the other subviews as you can see in the image below.(orange lines indicate the textviews).
Changing the color of the textview background makes no difference. What could i try?
EDIT ------ new image with TextFields.
Upvotes: 1
Views: 239
Reputation: 2294
Have your cell selection style to none and override setSelected method of tableView cell to change background color of cell.
{
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
@implementation CustomTableViewCell
-(void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
//--
self.contentView.backgroundColor = (selected) ? [UIColor grayColor]:[UIColor whiteColor];
}
@end
Upvotes: 0
Reputation: 6114
This issues caused by UITableViewCell
selection. When you select cell it changes backgroundColor
on all subviews. To prevent this you have two options:
1) Subclass UITableViewCell
and set color to subviews in:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
2) Setup color in tableView:didSelectRowAtIndexPath:
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell isSelected]) {
UIView *view = [cell viewWithTag:TEXTFIELD_TAG];
view.backgroundColor = [UIColor greenColor];
}
}
Upvotes: 2
Reputation: 618
If i have not misunderstood the question then You can try adding all these three text view in one uiview(container) . Then on didselect table view cell change the background color of that container view. Hope it helps.
Upvotes: 0