UITableView didSelectRowAtIndexPath not working after upgrade to iOS8

I have an iOS application with several UITableViews in which everything works as intended, I am updating the application to handle iOS8

since then I have had a problem loading a custom cell into a table view, whose nib was in the ib checked 'use auto layout' field. Then I uncheck all of these checkboxes in my custom cell, and since then the cells of all my UITableViews not only do not call the pathSelectRowAtIndex method, but also do not stand out by touch.

I verify that all cells are active by adding

if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");} 

all loaded cells write "included" in the log

I set the delegate and data source via ib in the storyboard, and all this worked before I changed the "use auto layout" and update to run on iOS 8.

what did I miss?

here is my code for creating cells

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TableCellWithNumberCellIdentifier"; if( events.count>indexPath.row &&[[[events objectAtIndex:indexPath.row] objectForKey:@"tag"] integerValue] == -1) { EventsMonthSeparator *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell.translatesAutoresizingMaskIntoConstraints=NO; cell = (EventsMonthSeparator *)[EventsMonthSeparator cellFromNibNamed:@"EventsMonthSeparator"]; cell.date.text=[[events objectAtIndex:indexPath.row] objectForKey:@"date"]; [Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES]; if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");} } return cell; }else { eventsRow *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell.translatesAutoresizingMaskIntoConstraints=NO; cell = (eventsRow *)[eventsRow cellFromNibNamed:@"eventsRow"]; cell.description.text=[[events objectAtIndex:indexPath.row] objectForKey:@"name"]; cell.timedate.text=[[events objectAtIndex:indexPath.row]objectForKey:@"date"]; cell.image.image=[UIImage imageNamed:@"tiledrinks"]; cell.status.text=[Functions statusForIndex:[[[events objectAtIndex:indexPath.row] objectForKey:@"booked"] intValue]]; [Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES]; cell.tag=1; [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");} } return cell; } } 
+5
source share
3 answers

Please check that Auto-Layout OFF (not tickMark selected) in your custom xib cell Also.

And in your TableView check this default setting. As shown in the image below enter image description here

I have the same problem when I gave NO Selection to the selection property of the TableView attribute inspector .

If you did the same, give Single selection there.

Hope this helps you!

+15
source

If you selected auto-layout, cell.translatesAutoresizingMaskIntoConstraints=NO; will override the automatic layout that Xcode provides. Also, you can check if all delegates have tableViews? If your delegate is not set, then clicking on the table view cell will not call the 'didSelectRow' method.

+2
source

You can select "in single selection during editing" in the TableView, for example: enter image description here

0
source

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


All Articles