Mark Gilchrist Mark Gilchrist - 5 months ago 9
Objective-C Question

UITableView didSelectRowAtIndexPath not working after upgrade to iOS8

I have an iOS app with several UITableViews in them all of which worked as intended
. I upgrade the app to handle iOS8

since then I had a problem with loading a custom cell into the table view who's nib had the box in the ib checked 'use auto layout'. I then uncheck all of these on my custom cell and since then the cells of all my UITableViews not only don't call didSelectRowAtIndex path method but are not highlighted on touch.

I have check that all the cells are active by adding

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


all of the loaded cells write 'is enabled' to the log

I am setting the delegate and data source via the ib in the storyboard and all of this was working prior to me changing the 'use auto layout' and upgrade to run on iOS 8.

what have i missed?

here is my code to create the 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;
}
}

Answer

Please Do check that Auto-Layout is OFF (Non selected tickMark) in your Custom cell's xib Also.

And in Your TableView check this default setting, As attached in below image enter image description here

I have same issue once, where I have give NO Selection in selection property of TableView's attribute inspector.

If you have done same then give Single selection there.

Hope this will help you !

Comments