这里有两个函数。
第一个函数是我为我的
当发生双击手势事件时,我试图从此函数向我的第二个函数发送indexPath。所以我的操作调用
在我的第二个函数中,我试图使用sender获取单元格的
当我点击第一个单元格时,如何只获取整数0?
欢迎提出任何建议。谢谢大家。
第一个函数是我为我的
UICollectionView
中的每个单元格提供手势。当发生双击手势事件时,我试图从此函数向我的第二个函数发送indexPath。所以我的操作调用
doubleTap:
。在我的第二个函数中,我试图使用sender获取单元格的
indexPath
。我能够得到一个indexPath
,当打印时,如果我双击第一个单元格,则输出"0xc000000000078016> {length = 2, path = 0 - 0}"。当我点击第一个单元格时,如何只获取整数0?
欢迎提出任何建议。谢谢大家。
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as myViewCell
//adding single and double tap gestures for each cell
/////////////////////////////
//ISSUE IS SENDING indexPath TO doubleTap FUNC
var gestureDoubleTap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "doubleTap:")
gestureDoubleTap.numberOfTapsRequired = 2
cell.addGestureRecognizer(gestureDoubleTap)
var gestureSingleTap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "singleTap")
gestureSingleTap.numberOfTapsRequired = 1
cell.addGestureRecognizer(gestureSingleTap)
cell.imgView.image=UIImage(named: imageArray[indexPath.row])
return cell
}
func doubleTap(sender: UITapGestureRecognizer) {
var tapLocation = sender.locationInView(self.collectionView)
var indexPath:NSIndexPath = self.collectionView.indexPathForItemAtPoint(tapLocation)!
//var cell = self.collectionView.cellForItemAtIndexPath(indexPath)
NSLog("double tap")
NSLog("%@", indexPath)
//NSLog("%@", cell!)
//name = imageArray[indexPath]
//self.performSegueWithIdentifier("segue", sender: nil)
}