UITableViewCell no userInteraction but on cell.accessoryView

Posted by Simon on Stack Overflow See other posts from Stack Overflow or by Simon
Published on 2010-05-14T00:17:44Z Indexed on 2010/05/14 0:24 UTC
Read the original article Hit count: 712

hello genius and nerds

I have a TableViewCell with a UISwitch in accessoryView. I don't want that blue background if someone selected it. There fore i used

cell.userInteractionEnabled = NO;

but then the whole cell isnt accessable so i tried that

cell.userInteractionEnabled = NO;
cell.accessoryView.userInteractionEnabled = YES;

i think this wont work because cell is the parent of the accessoryView. but how can i manage this issue ? A hint in the right direction would be great.

Simon

Here is the complete cellForRowAtIndexPath method:

cell.textLabel.text = @"dasda";
cell.userInteractionEnabled = NO;
cell.accessoryType = UITableViewCellAccessoryNone;

UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
mySwitch.tag = row;
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
cell.accessoryView.userInteractionEnabled = YES;

[(UISwitch *)cell.accessoryView setOn: YES];
[(UISwitch *)cell.accessoryView addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventValueChanged];

return cell;

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk