Swift 如何在单击屏幕上的UI开关时获取特定tableviewcell的ID

Swift 如何在单击屏幕上的UI开关时获取特定tableviewcell的ID,swift,uitableview,Swift,Uitableview,我面临UITableViewCell问题。我有使用解析生成的动态数据列表。现在用户将使用UISwitch选中/取消选中该单元格。我必须存储该用户操作并将其发送到其他viewController func tableView(tableView:UITableView,cellForRowAtIndexPath:nsindepath)->UITableView单元格{ 将单元格:HotspotCustomCell=tableView.dequeueReusableCellWithIdentifie

我面临UITableViewCell问题。我有使用解析生成的动态数据列表。现在用户将使用UISwitch选中/取消选中该单元格。我必须存储该用户操作并将其发送到其他viewController

func tableView(tableView:UITableView,cellForRowAtIndexPath:nsindepath)->UITableView单元格{
将单元格:HotspotCustomCell=tableView.dequeueReusableCellWithIdentifier(“htuiViewCell”)设为!HotspotCustomCell
设singleHotspot=hospots[indexPath.row]
cell.sendCell(singlehospot.hospotid,hospotimg:singlehospot.hospotimage,hospotlbl:singlehospot.hospotname)
返回单元
}

如何获取UITableViewCell中已选中的项目。 试试这个

 // Declare inside your Class file
 var customIndexPath: NSIndexPath = NSIndexPath()


 //Add this inside didSelectRowAtIndexPath
 customIndexPath = indexPath
 println(customIndexPath)


 //Create an IBAction on switch
 @IBAction func switchOnOFF(sender: AnyObject) {

   println(customIndexPath)
   //Use the customIndexPath variable inside your Switch action
 }

选择特定单元格时会调用didSelectRowAtIndexPath。但我想获取uiSwitch事件中的特定单元格数据。我已为此添加了答案。谢谢karios。但此事件只有在他将tab tableviewcell时才会获取文件。我希望选项卡切换时不在tableviewcell上显示数据。您可以将标记用于切换,并为两个切换创建公共iAction。根据标记值,您可以执行相应的操作。但我无法在标记中存储字符串值。对于单元格1,请使用开关标记作为1。与单元格2类似,使用开关标签作为2。在您的操作中,检查标记等于1,然后在单元格1开关上执行操作。
 // Declare inside your Class file
 var customIndexPath: NSIndexPath = NSIndexPath()


 //Add this inside didSelectRowAtIndexPath
 customIndexPath = indexPath
 println(customIndexPath)


 //Create an IBAction on switch
 @IBAction func switchOnOFF(sender: AnyObject) {

   println(customIndexPath)
   //Use the customIndexPath variable inside your Switch action
 }