Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
    }
}
like image 724
Mark Gilchrist Avatar asked Oct 18 '14 21:10

Mark Gilchrist


3 Answers

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 !

like image 151
Vishal Sharma Avatar answered Nov 13 '22 05:11

Vishal Sharma


If you have selected auto layout, cell.translatesAutoresizingMaskIntoConstraints=NO; will negate the auto layout that Xcode provides. Also, could you check if all your tableViews' delegates are intact? If your delegate isn't set, the tapping on table view cell will not invoke the 'didSelectRow' method.

like image 42
Gaurav Wadhwani Avatar answered Nov 13 '22 05:11

Gaurav Wadhwani


You can select "in single selection During Editing" in TableView, for example: enter image description here

like image 1
RckLN Avatar answered Nov 13 '22 04:11

RckLN