I'm in the middle of trying to debug an issue with a new app, and something isn't right. In the app, I'm setting up custom UITableViewCells by adding 2 UILabels and 1 UIImageView directly to the cell.contentView
In my app, certain table view cells werent selectable ( they werent responding to tap events ). The 2nd cell on the screen was always never selectable, and then random other cells also werent selectable.
In my effort to debug, I stripped everything down the following bare essentials of code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ReviewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = @"foo";
return cell;
}
Even this is generic, boiler plate code, that looks like the following:
not all the cells are selectable.
What am I missing?
update
as an updated here is my row selection code if interested
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ReviewWebViewController *rvc = [[ReviewWebViewController alloc] initWithReview:[self.reviews objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:rvc animated:YES];
[rvc release], rvc=nil;
}
A lot of things have been mentioned, which I will not re-iterate.
But make sure that the elements you add to the UITableViewCell have their userInteractionEnabled
set to NO
. Especially when not using IB, never make too many assumptions about defaults.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With