전 화면 가로 뷰가 있습니다.collectionview 셀에서 uiview에 제스처 인식기를 추가하는 방법
- 스크롤은 페이징에 대한 다음/이전 버튼이 있습니다,
- 페이징이 사용되지 않습니다.
내 collectionview 셀에는 사용자가 왼쪽/오른쪽으로 스 와이프 할 때 인식 할 레이블이 있습니다. 제스처를 레이블에 추가 한 후에 아무 일도 일어나지 않습니다.
CODE :
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에서 대상을 전환을 시도하고 그것은 여전히 작동하지 않습니다. 당신은뿐만 아니라 뷰 컨트롤러의 와이프를 처리 할 수 있도록
감사
감사합니다 , 인스턴스로 인식 할 수없는 선택기를 보냈습니다. – ilan
뷰 컨트롤러에도'test :'를 구현 했습니까? 그렇지 않으면 오류가 발생합니다. 무엇을 설정하든'target'은 그 selector를 구현해야합니다. – trevorj
위대한 작품, 테스트를 추가하는 것을 잊어 버렸습니다. – ilan