views:

501

answers:

2

I'm having an issue with UITableView's didSelectRowAtIndexPath.

My table is setup so that when I select row it initializes a new view controller and pushes it.

The first time I tap any row in the table, the method does not get called. Once I select another row, it begins to work as normal.

I have verified this by setting a breakpoint on didSelectRowAtIndexPath. When adding an NSLog to the method I see that when I select the second row that finally pushes the new view controller, I see two log statements appear in the console at the same time.

Any suggestions?

+7  A: 

Any chance you accidentally typed didDeselectRowAtIndexPath?

Ole Begemann
Wow. Definitely break time. Thanks!
CrystalSkull
Oh god, Intelisense 2, users 0. Thank you Ole.
Rigo Vides
If I could kiss you right now I would. I spent over two hours looking at this and didn't see it. Sheesh.
MikeyWard
A: 

I got a same problem. I found nothing wrong with my code bellow, but cannot figure out how to get it called.

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    NSLog(@"didSelectRowAtIndexPath get called");
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSString* name = [data objectAtIndex:indexPath.row];
    //show the name
    NSString *message = [NSString stringWithFormat:@"Hey, %@!, How are you?", name];
    UIAlertView *alertView = [[UIAlertView alloc] init];
    [alertView setMessage:message];
    [alertView addButtonWithTitle:@"OK"];
    [alertView setTitle:@"Hey"];
    [alertView show];
    [alertView release];
    //deselect
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Hung