Select UITableView's row when clicking on UISwitch

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

I have a UITableView with UISwitchs on them.

\"TableView\"

When the switch is

7条回答
  •  情话喂你
    2020-12-06 08:29

    You should set the IndexPath.row as a Tag to each Switch in cellForRowAtIndexPath Method

     switchView.tag= indexPath.row;
    

    And when switch value change .you'll get the Row number

    - (void) switchChanged:(UISwitch *)sender {
      int rowIndex =[sender tag];
      //rowIndex you may use it further as you wanted.   
    

    }

提交回复
热议问题