didSelectItemAt在长按后调用的indexPath

时间:2016-11-10 13:22:11

标签: ios swift uicollectionview uicollectionviewcell

我使用了collectionview并在集合视图单元格中设置了imageview。我需要在触摸单元格后移动另一个viewcontroller。但我的问题是在集合视图中长按单元格后视图会移动。 这是我的代码。

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
    let imagesPath = documentPath.appendingPathComponent(reportImageFolder)
    let cell = arrImagesFiltered[indexPath.item]
    let imageNameWithPath = "\(imagesPath)/\(cell)"
    let imageEditViewController = self.storyboard?.instantiateViewController(withIdentifier: "EditImageViewController") as! EditImageViewController
    imageEditViewController.imagePath = imageNameWithPath
    self.navigationController?.pushViewController(imageEditViewController, animated: true)

}

1 个答案:

答案 0 :(得分:0)

对于这个老问题的未来读者-将来可能是我;)

我有一个UITapGestureRecognizer吞噬了我的短水龙头,因此只有旧水龙头才能通过!您只需要添加tapRecognizer.cancelsTouchesInView = false

let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapDidTouch(sender:)))
tapRecognizer.cancelsTouchesInView = false
scrollView.addGestureRecognizer(tapRecognizer)