How to tell when a UISwitch inside of a UITableViewCell has been tapped?
Posted
by RexOnRoids
on Stack Overflow
See other posts from Stack Overflow
or by RexOnRoids
Published on 2010-03-27T07:33:14Z
Indexed on
2010/03/27
7:43 UTC
Read the original article
Hit count: 1179
How to tell when a UISwitch inside of a UITableViewCell has been tapped?
My UISwitch is set up inside of the cell (generic cell) like this:
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
And I am trying to detect a tap like this (but its not working):
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSUserDefaults *prefs;
if(indexPath.section == 1){
switch(indexPath.row)
{
case 0:
NSLog(@"Tapped Login Switch");
break;
default:
break;
}
}
}
© Stack Overflow or respective owner