【发布时间】:2017-04-03 15:27:31
【问题描述】:
我在 uitableview 的一个单元格中有两个图像,这些图像显示为来自外部服务器的图像,并且它们的每个标签都有一个该图像代表的项目 id,如果我单击此图像,我需要将用户移动到新视图显示此项目详细信息的控制器,我强制一个问题,用户需要双击以显示详细信息而不是单击,以下是我的代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = self.tableView.cellForRow(at: indexPath as IndexPath) as! prodctCell
Id1stMove = cell.image1st.tag
let tapGesture = UITapGestureRecognizer (target: self, action: #selector(ItemsController.imgTap))
cell.image1st.addGestureRecognizer(tapGesture)
cell.image1st.isUserInteractionEnabled = true
let cell1 = self.tableView.cellForRow(at: indexPath as IndexPath) as! prodctCell
Id2ndMove = cell1.image2nd.tag
let tapGesture1 = UITapGestureRecognizer (target: self, action: #selector(ItemsController.imgTap1))
cell1.image2nd.addGestureRecognizer(tapGesture1)
}
func imgTap()
{
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "testViewController") as? testViewController
let navController = UINavigationController(rootViewController: secondViewController!)
navController.setViewControllers([secondViewController!], animated:true)
self.revealViewController().setFront(navController, animated: true)
revealViewController().pushFrontViewController(navController, animated: true)
secondViewController?.movmentId = Id1stMove
updateCount(itemId: Id1stMove)
}
【问题讨论】:
-
您的实际问题是什么?
-
您需要双击吗?还是在您执行双击之前该行为不会发生?
-
我需要点击一下才能移动到另一个视图而不是双击
-
为什么要在
didSelectRowAt方法中添加点击手势?这根本没有意义。
标签: ios swift uitableview