UITableViewCell will not be highlighted

For some reason, none of my UITableViewCell highlights blue. In IB, I have it set to highlight blue, and I don't have a code that overrides IB.

Have you noticed anything that might cause this?

enter image description here

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int showID = [[[singleton.programs objectAtIndex:indexPath.row]objectForKey:@"id"]intValue]; //creates the url and loads the list of products //NSLog(@"showID: %d", showID); URLCreator * productsURL = [[URLCreator alloc] initStandard:@"getProgramProductsForList"]; [productsURL addParam:@"id" stringValue:[NSString stringWithFormat:@"%d", showID]]; WebManager *productsWM = [[WebManager alloc]init]; [productsWM load:[productsURL finalURL] withSelector:@selector(parseProducts) object:[NSNumber numberWithInt:showID]]; } 

My user cell currently has nothing but `@ property / @ synthesize @, but here it is.

 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } 
+4
source share
7 answers

Your case is simple enough that the best way to solve it is probably to make a minimal example that works correctly (the default table view cell with a blue selection) and adds to it step by step (or in binary search steps) until it won't break

If the minimal code breaks after some addition, you pinpoint the problem. If this is not the case, and you actually achieved the same thing that you seem to be using in your project, compare and see what difference you have not noticed.

+4
source

Have you tried this ...?

 [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; 
+4
source

Here is the mistake I made in the past. Is your UITableView in edit mode? If so, is the selection enabled during editing?

By default, it is not enabled. In Interface Builder, select UITableView and find the "Edit" property in the "View Table" section of the "Utilities" panel. Be sure to select "One choice when editing."

Also check that "Single Selection" is enabled at all.

+1
source

Maybe a fleeting answer, but just to cover simple things, did you make sure you assigned the table view cell to your custom subclass of UITableViewCell?

Custom class assignment

+1
source

Were your cell subzones occupied by all cell boundaries and completely opaque? if so, even already highlighted in blue, the effect will not be visible.

0
source

No, I deleted all the subitems. I even started a new TableViewController with a button that appears directly from the main screen for verification purposes only. Still no. This is strange. The only time I can get selected for work is a completely new project. - James yesterday

As you note, this only happens in this project, and not when starting a new project you tried to clean the project in Xcode (Product> Clean) and remove the application from the simulator? Run again. Solves many odd problems.

0
source

You said that this does not happen in new projects, did you try to create a new storyboard in your project to make sure that this has any effect?

The .storyboard file is just an xml file and maybe something bad in the XML file ... it doesn't hurt to try.

0
source

Source: https://habr.com/ru/post/1397796/


All Articles