美文网首页
iOS开发笔记-104:Swift5 - collectionV

iOS开发笔记-104:Swift5 - collectionV

作者: 原味蛋炒饭 | 来源:发表于2020-03-03 09:45 被阅读0次
let longRG = UILongPressGestureRecognizer.init(target: self, action: #selector(loneAct(_:)))
        collectionView.addGestureRecognizer(longRG)


@objc func loneAct(_ sender: UILongPressGestureRecognizer) {
        let touchpoint = sender.location(in: collectionNode.view)
        
        if sender.state == .began {
            let indexpathN = collectionNode.indexPathForItem(at: touchpoint)
            
            self.indexpath = indexpathN
            if self.indexpath == nil {
                JJLog("点击到空白处")
            } else {
                JJLog("点击")
                JJLog(self.indexpath?.section)
                JJLog(self.indexpath?.row)
            }
        }        
    }

相关文章

网友评论

      本文标题:iOS开发笔记-104:Swift5 - collectionV

      本文链接:https://www.haomeiwen.com/subject/iqgflhtx.html