【问题标题】:How to hide all CollectionViewCell when user slides and tap fingers on them (uses touch gestures)?当用户滑动并点击手指(使用触摸手势)时如何隐藏所有 CollectionViewCell?
【发布时间】:2018-02-13 05:09:01
【问题描述】:

我正在 iOS 中开发屏幕测试应用程序,我想在用户滑动并点击手指时隐藏所有 CollectionViewCell。 我使用过 touchesBegan、touchesMoved、touchesEnded 方法,但没有奏效。也对其他逻辑开放。

下面是 CollectionView 的截图。

【问题讨论】:

  • “滑动和点击手指”同时?
  • Yes for tap do select is there, I want both together
  • “用户滑动” - 什么样的?水平垂直?火种类型?
  • 所有方向上、下、左、右
  • 要处理这种情况,你需要在UICollectionView上创建UITapGesture,而点击滚动控制器(UITableView,UICollection)不会调用touchesBegan方法。因为它们有自己的选择器方法。这是指导您的链接,如何在 UICollectionView 上创建 Tap Gesture,借助此您还将获得另一个手势想法。 useyourloaf.com/blog/collection-view-default-gestures

标签: ios uicollectionview autolayout swift4


【解决方案1】:
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
        let point: CGPoint = gesture.location(in: collectionBlocks)
        if let theIndexPath: IndexPath = collectionBlocks.indexPathForItem(at: point)
        {
            let selectedCell = collectionBlocks.cellForItem(at: theIndexPath)
            selectedCell?.backgroundColor = UIColor.clear
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-06
    • 1970-01-01
    • 2018-05-06
    相关资源
    最近更新 更多