Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView didSelectRowAtIndexPath: Not Working

When I select the table row, nothing happens. It didn't go to ContentController and I can't find the UILabel that I declared on ContentController.h when I want to link it to resultLabel.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ContentController *detailview = [[ContentController alloc] initWithNibName:@"ContentController" bundle:nil];    
    detailview.detailString = [NSString stringWithFormat:@"%d",indexPath.row];
    [self.navigationController pushViewController:detailview animated:YES];     
    [detailview release];
}

ContentController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    resultLabel.text = self.detailString;
}
like image 534
JBL Avatar asked Nov 30 '22 07:11

JBL


2 Answers

This may be because you don't have set your table view property to delegate & datasource by:

tableview.delegate=self;
tableview.datasource=self;

or set their property in xib is another option

like image 93
Aakil Ladhani Avatar answered Dec 04 '22 07:12

Aakil Ladhani


clickable == NO

Can be a state that in the method cellForRowAtIndexPath :

cell = [self tableCellWithHeight:height clickable:NO withArrowAccessory:NO];

if clickable == NO then didSelectRowAtIndexPath method will never called for that cell.

like image 34
evya Avatar answered Dec 04 '22 07:12

evya