I have a very simple tableview in a xib file with it’s delegate and datasource hooked up to TestVC. TestVC is simple:
#import "TestVC.h"
@implementation TestVC
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *IDEN = @"IDEN";
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:IDEN];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:IDEN];
}
cell.textLabel.text = @"test";
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (void)tableView:(UITableView *)_tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"called");
[_tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
When I click on a cell, it doesn’t get deselected. I even put a log statement there to see if didDeselectRowAtIndexPath method is being called and it is.
What am i doing wrong?
You are using the wrong method
– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
is the one you need