【发布时间】:2014-12-30 08:01:17
【问题描述】:
我有一个全屏水平collectionview。
- 滚动已禁用
- 分页已启用,分页有下一个/上一个按钮。
在我的 collectionview 单元格中,我有一个标签,当用户向左/向右滑动它时我想识别它。 在我将手势添加到标签后,没有任何反应。
代码:
collectionViewCell:
func addGesture(){
let right = UISwipeGestureRecognizer(target: myLabel, action: "test")
right.direction = UISwipeGestureRecognizerDirection.Left
answer.addGestureRecognizer(right)
}
视图控制器:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("formQuestionCell", forIndexPath: indexPath) as QuestionCell
cell.addGesture()
return cell
}
我也尝试将目标从 myLabel 切换到 self ,但它仍然不起作用。
谢谢
【问题讨论】:
标签: ios swift uigesturerecognizer uicollectionviewcell