Select UITableView's row when clicking on UISwitch

后端 未结 7 828
眼角桃花
眼角桃花 2020-12-06 07:45

I have a UITableView with UISwitchs on them.

\"TableView\"

When the switch is

相关标签:
7条回答
  • 2020-12-06 08:46

    I had to do double mySwitch.superview.superview to get the proper cell.

    Here's an example

    - (void)switchToggle:(UISwitch *)mySwitch
    {
    
     UITableViewCell *cell = (UITableViewCell *)mySwitch.superview.superview;
     NSIndexPath *indexpath = [self.tableView indexPathForCell:cell];
     NSLog(@"toggle section %d rowID %d", indexpath.section, indexpath.row);
    
    }
    
    0 讨论(0)
提交回复
热议问题