PDA

View Full Version : UITableViewCell and a custom tappable accessory




SqueegyX
Oct 30, 2008, 08:08 PM
According to the docs, I set a custom view to the accessoryView property of a table cell. And, according to the docs, and I make it tappable (like a UITableViewCellAccessoryDisclosureButton) by setting the userInteractionEnabled property of the accessory view to YES.

Sadly, its not working. This code works great if I use the UITableViewCellAccessoryDisclosureButton, but with my custom view tapping the accessory is ignored.

UIImageView *accessory = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EquipAccessory.png"]];
accessory.userInteractionEnabled = YES;
cell.accessoryView = accessory;
[accessory release];

Am I missing something here?

EDIT:

I realized the docs say the userInteractionEnabled property needs to be set on the cell, not the accessory. But it still isnt working. Even explicitly setting the target and action isn't working.

UIImageView *accessory = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EquipAccessory.png"]];
cell.accessoryView = accessory;
accessory.userInteractionEnabled = YES;
[accessory release];

cell.accessoryAction = @selector(tappedEquipButton:);
cell.userInteractionEnabled = YES;
cell.target = self;