Following the advice in this answer Custom UITableViewCell selection style? about how to make a custom selection style for a UITableViewCell
I did the following.
First, in my custom view controller, which has a UITableView
as a property and which serves as its datasource and delegate I have the following:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//UITableViewCell *cell;
NavTableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Then this is my entire custom UITableViewCell:
#import "NavTableViewCell.h"
@implementation NavTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if(highlighted){
self.contentView.alpha = .5;
}else{
self.contentView.alpha = 1;
}
}
@end
I have also tried putting the code in setSelected
. In both cases I don't see any change in my selected/highlighted table view cell. I have tried changing its color and changing the colors of the labels within it, but there is simply no change. I have also tried going through all the kinds of selection styles for the cell, all to no avail as far as seeing my customization.
What am I doing wrong?