上記の画像の様にUITableViewにUISwitchを設置しています。
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell") as! CustomTableViewCell cell.textLabel!.text = member.memberNames[indexPath.row] return cell } }
class CustomTableViewCell: UITableViewCell { @IBOutlet weak var mySwitch: UISwitch! @IBAction func hundleSwitch(_ sender: Any) { if mySwitch.isOn{ print("on") } else { print("off") } } }
現状上記の様にCustomTableViewCellにUISwitchを接続してSwitchをオン・オフするとprintで文字を出力するようにしております。
何番目のセルのSwitchが変更されたか、インデックス番号を取得する方法を
どなたかご教示いだだけませんでしょうか。
よろしくお願いいたします。

回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2017/06/07 04:34