我面臨一個問題UITableViewCell.I有使用parse生成的動態數據列表。現在用戶將使用UISwitch檢查/取消選中該單元格。我必須存儲該用戶操作並將其發送到其他viewController。如何獲取特定tableviewcell的ID點擊它上面的uiswitch
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: HotspotCustomCell = tableView.dequeueReusableCellWithIdentifier("htuiViewCell") as! HotspotCustomCell let singleHotspot = hotSpots[indexPath.row] cell.sendCell(singleHotspot.hotspotID, hotspotImg: singleHotspot.hotspotImage, hotspotLbl: singleHotspot.hotspottName) return cell }
func sendCell(hotspotID : String ,hotspotImg : PFFile , hotspotLbl : String) {
var tempImage:UIImage!
hotspotImg.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
/*Setting up the veriable tempImage.*/
tempImage = UIImage(data:imageData)
self.hotspotImage.image = tempImage
self.hotspotImage.layer.cornerRadius = self.hotspotImage.frame.size.width/2
self.hotspotImage.clipsToBounds = true
self.hotspotLabel.text = hotspotLbl
}
}
}
}
didSelectRowAtIndexPath在您選擇特定單元格時被調用。 – Karlos
但我想在uiSwitch事件上獲取特定的單元格數據。 –
我已經爲此添加了答案。 – Karlos