Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionViewCell上的双击手势?_Ios_Swift_Uicollectionviewcell_Uitapgesturerecognizer - Fatal编程技术网

Ios UICollectionViewCell上的双击手势?

Ios UICollectionViewCell上的双击手势?,ios,swift,uicollectionviewcell,uitapgesturerecognizer,Ios,Swift,Uicollectionviewcell,Uitapgesturerecognizer,我想双击UICollectionViewCell以喜欢该配置文件,就像OkCupid应用程序一样。我已经在集合视图上应用了点击手势,但它不起作用 当我每次尝试双击单元格时,didSelectCollectionViewCell方法调用。您是否已将UITapEstiureRecognitizer属性设置为所需的数目:设置为2?您是否已将UITapEstiureRecognitizer属性设置为所需的数目:设置为2?您必须添加将手势识别器双击到集合视图而不是单元格。在其动作选择器中,您可以确定双击了

我想双击UICollectionViewCell以喜欢该配置文件,就像OkCupid应用程序一样。我已经在集合视图上应用了点击手势,但它不起作用


当我每次尝试双击单元格时,
didSelectCollectionViewCell
方法调用。

您是否已将
UITapEstiureRecognitizer
属性设置为所需的数目:设置为2?

您是否已将
UITapEstiureRecognitizer
属性设置为所需的数目:设置为2?

您必须添加将手势识别器双击到集合视图而不是单元格。在其动作选择器中,您可以确定双击了哪个单元格

override func viewDidLoad() {
     var doubleTapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "didDoubleTapCollectionView:")
     doubleTapGesture.numberOfTapsRequired = 2  // add double tap
     self.collectionView.addGestureRecognizer(doubleTapGesture)
}

func didDoubleTapCollectionView(gesture: UITapGestureRecognizer) {
     var pointInCollectionView: CGPoint = gesture.locationInView(self.collectionView)
     var selectedIndexPath: NSIndexPath = self.collectionView(forItemAtPoint: pointInCollectionView)
     var selectedCell: UICollectionViewCell = self.collectionView.cellForItemAtIndexPath(selectedIndexPath)
     // Rest code
}

您必须将双击手势识别器添加到集合视图而不是单元格。在其动作选择器中,您可以确定双击了哪个单元格

override func viewDidLoad() {
     var doubleTapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "didDoubleTapCollectionView:")
     doubleTapGesture.numberOfTapsRequired = 2  // add double tap
     self.collectionView.addGestureRecognizer(doubleTapGesture)
}

func didDoubleTapCollectionView(gesture: UITapGestureRecognizer) {
     var pointInCollectionView: CGPoint = gesture.locationInView(self.collectionView)
     var selectedIndexPath: NSIndexPath = self.collectionView(forItemAtPoint: pointInCollectionView)
     var selectedCell: UICollectionViewCell = self.collectionView.cellForItemAtIndexPath(selectedIndexPath)
     // Rest code
}

UICollectionviewcell而不是UIcollectionView上应用UITappostation,并在自定义UICollectionviewcell中处理选择,并将所需的属性编号设为2…..

UICollectionviewcell上应用UITappostation而不是UIcollectionView并处理自定义UICollectionViewCell中的选择,并将属性numberofTapsRequired设置为2…..

出现错误:无法调用非函数类型“UIcollectionView!”的值是因为你试图使用错误的方法

请尝试使用此选项:

var selectedIndexPath: NSIndexPath = self.collectionView.indexPathForItemAtPoint(pointInCollectionView)

出现错误:无法调用非函数类型“UICollectionView!”的值是因为你试图使用错误的方法

请尝试使用此选项:

var selectedIndexPath: NSIndexPath = self.collectionView.indexPathForItemAtPoint(pointInCollectionView)

上述代码给出了一个错误,无法调用非函数类型“UICollectionView!”的值听起来您的collectionview中有错误检查您的collectionview上述方法不存在,请在答复时提供有效的可编译代码,以免混淆其他初学者。上述代码给出了一个错误,无法调用非函数类型“UICollectionView!”的值听起来像是collectionview中的错误检查collectionview上述方法不存在,请在答复时提供有效的可编译代码,以免混淆其他初学者开发人员。