4
我正在嘗試在UITableViewCell內部的UIImageView上檢測點擊手勢。在UITableViewCell中未檢測到點擊手勢
這是代碼的內部cellForRowAtIndexPath
部分:
let cell1 : cellTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! cellTableViewCell
tableView.allowsSelection = false
cell1.profileImg.userInteractionEnabled = true
let tappedOnImage = UIGestureRecognizer(target: cell1, action: "tappedOnImage:")
cell1.profileImg.tag = indexPath.row
cell1.profileImg.addGestureRecognizer(tappedOnImage)
而這裏的處理手勢的功能:
func tappedOnImage(sender:UITapGestureRecognizer){
print("hey")
}
然而,當我點擊..任何建議,什麼也沒有發生?
除非你tappedOnImage功能在類cellTableViewCell實現。如果是這種情況,那麼我會嘗試添加該類中的手勢識別器,而不是cellForRowAtIndexPath。 – drewfus
我試過「自我」,它不工作... – dpstart
YEs一切都在cellForRowAtIndexPath – dpstart