iPhone SDK: Why is didSelectRowAtIndexPath not being fired?
- by iPhone Developer
I have a view with a table on it. When the app starts, it loads the first 5 visble cells. That works as expected.
My problem is that, when I try to scroll down in the table the app crashes with this error.
What I've found is that didSelectRowAtIndexPath is not being called. AFAIK, all I need to do is to subscribe to the delegate. But I must be missing something?
@interface LandingRetailersViewController : TableSectionHeaderViewController<UITableViewDataSource, UITableViewDelegate, UITabBarDelegate> {
Any help appreciated.
2010-06-06 12:25:42.547
iphoneos[18238:207] * -[NSCFString
tableView:cellForRowAtIndexPath:]:
unrecognized selector sent to instance
0x451a980 2010-06-06 12:25:42.549
iphoneos[18238:207] Terminating
app due to uncaught exception
'NSInvalidArgumentException', reason:
'** -[NSCFString
tableView:cellForRowAtIndexPath:]:
unrecognized selector sent to instance
0x451a980'
Here is my code to load cells.
UITableViewCell * cell = nil;
NSInteger index = [indexPath indexAtPosition:1];
NSLog(@"WHAT IS INDEX %i", indexPath);
RoundedGradientTableViewCell *retailerCell = (RoundedGradientTableViewCell *)[tb dequeueReusableCellWithIdentifier:@"RET"];
if(!retailerCell){
retailerCell = [[[RoundedGradientTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RET"] autorelease];
}
[retailerCell setArcSize:5.0];
[retailerCell setStrokeSize:1.0];
[retailerCell setStrokeColor:[UIColor clearColor]];
[retailerCell setBackgroundFillColor:[UIColor clearColor]];
[retailerCell setBackgroundColor:[UIColor clearColor]];
Retailer *retailer = [self retailerAtIndex:index];
if(retailer){
[[retailerCell textLabel] setText:[retailer name]];
if([retailer hasImage]){
[[retailerCell contentImageView] setImage:[retailer image]];
}
} else {
[[retailerCell textLabel] setText:@"No title"];
}
cell = retailerCell;
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
NSLog(@"retailer: %@ ", [retailer name]);
NSLog(@"log: %i ", index);
return cell;