I created a UITableViewCell in Interface Builder which I have added a UIImageView and a UIButton to. I have given the UIButton an outlet, and hooked it up to a IBAction with the touch up inside event set. I assumed it would call this method, as everything looked like it is hooked up:
- (IBAction)pressedCheckbox:(id)sender {
[sender setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
NSLog(@"clicked check");
}
Checking the connections tab, I have everything set correctly, the outlet and the action. And I get no errors, but when previewing the app, clicking on that button inside the UITableViewCell does nothing, and I don't see anything in the logs.
Ideas on why it won't let me click my button which is in a UITableViewCell?
EDIT:
Code for cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0:
cell = topCell;
break;
case 1:
cell = cell1;
break;
}//end switch
}//end if
return cell;
}