ios - UICollectionView:将点击手势识别器添加到 collectionView super View
<p><p> Collection View 不称为 <code>didSelectItemAtIndexPath</code>。当我将点击手势识别器添加到 <code>collectionView</code>superView 时,它总是响应点击手势方法。 </p>
<p>请帮助我,在此先感谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个</p>
<pre><code>func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
let touchPoint = touch.locationInView(superView)
return !CGRectContainsPoint(collectionView.frame, touchPoint)
}
</code></pre>
<p>并确保代理已连接:</p>
<pre><code>tapGestureRecognizer.delegate = self
</code></pre></p>
<p style="font-size: 20px;">关于ios - UICollectionView:将点击手势识别器添加到 collectionViewsuperView ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38009292/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38009292/
</a>
</p>
页:
[1]